2021-12-11 09:49:09 +08:00
|
|
|
|
#ifndef UDISKSYSTEMRESTOREPROXY_H
|
|
|
|
|
#define UDISKSYSTEMRESTOREPROXY_H
|
|
|
|
|
|
|
|
|
|
#include "workerfactory.h"
|
|
|
|
|
#include "myprocess/rsyncpathtodirprocess.h"
|
|
|
|
|
#include "parsebackuplist.h"
|
|
|
|
|
|
|
|
|
|
class UDiskSystemRestoreProxy : public Worker
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
DECLARE_DYNCREATE(UDiskSystemRestoreProxy)
|
|
|
|
|
public:
|
|
|
|
|
// 系统还原的几种场景
|
|
|
|
|
enum SystemRestoreScene {
|
2022-01-25 16:15:41 +08:00
|
|
|
|
RESTORE_SYSTEM_WITH_DATA, // 保留用户数据还原
|
2021-12-11 09:49:09 +08:00
|
|
|
|
SYSTEM_RESTORE, // 系统还原
|
|
|
|
|
EFI_RESTORE, // efi还原
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
explicit UDiskSystemRestoreProxy();
|
|
|
|
|
virtual ~UDiskSystemRestoreProxy();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// 环境检测
|
|
|
|
|
virtual bool checkEnvEx();
|
|
|
|
|
|
|
|
|
|
// 任务处理
|
|
|
|
|
virtual void doWorkEx();
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
bool checkUdiskExists();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// 还原efi
|
|
|
|
|
bool restoreEfi();
|
|
|
|
|
// 修复efi目录
|
|
|
|
|
void repairEfi();
|
|
|
|
|
// 以读写方式重新挂载efi分区
|
|
|
|
|
void remountEfi();
|
|
|
|
|
// 以读写方式重新挂载boot分区
|
|
|
|
|
void remountBoot();
|
|
|
|
|
// 同步efi
|
|
|
|
|
bool rsyncEfi();
|
|
|
|
|
// 系统还原
|
|
|
|
|
void restoreSystem();
|
|
|
|
|
// 还原前准备
|
|
|
|
|
bool doPrepare();
|
|
|
|
|
// 异机还原时更新grub.cfg中的分区UUID
|
|
|
|
|
void updateGrubUUid();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 根据场景获取rsync命令参数
|
|
|
|
|
* @param scene,场景
|
|
|
|
|
* @return 组装好的rsync的参数信息
|
|
|
|
|
*/
|
|
|
|
|
QStringList getRsyncArgs(SystemRestoreScene scene);
|
|
|
|
|
|
|
|
|
|
// .user.txt文件路径
|
|
|
|
|
QString m_userFile;
|
|
|
|
|
// .exclude.user.txt文件路径
|
|
|
|
|
QString m_excludeUserFile;
|
|
|
|
|
// 备份数据所在的data目录
|
|
|
|
|
QString m_backupPath;
|
|
|
|
|
|
|
|
|
|
// 是否还原结束
|
|
|
|
|
bool m_isFinished;
|
|
|
|
|
// 当前备份uuid
|
|
|
|
|
QString m_curUuid;
|
|
|
|
|
// 当前还原源目录
|
|
|
|
|
QString m_srcPath;
|
|
|
|
|
// 备份进程
|
|
|
|
|
RsyncPathToDirProcess *m_p;
|
|
|
|
|
// 当前备份节点
|
|
|
|
|
ParseBackupList::BackupPoint m_backupPoint;
|
2022-03-09 16:54:25 +08:00
|
|
|
|
// 强制结束标志(stop后没反应的情况,系统处于睡眠状态)
|
|
|
|
|
bool m_isForce;
|
2021-12-11 09:49:09 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // UDISKSYSTEMRESTOREPROXY_H
|