yhkylin-backup-tools/backup-daemon/systemrestoreproxy.h

88 lines
2.7 KiB
C++
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef SYSTEMRESTOREPROXY_H
#define SYSTEMRESTOREPROXY_H
#include "workerfactory.h"
#include "myprocess/rsyncpathtodirprocess.h"
#include "parsebackuplist.h"
class SystemRestoreProxy : public Worker
{
Q_OBJECT
DECLARE_DYNCREATE(SystemRestoreProxy)
public:
// 系统还原的几种场景
enum SystemRestoreScene {
SYSTEM_RESTORE, // 系统还原
RESTORE_SYSTEM_WITH_DATA, // 保留用户数据还原
EFI_RESTORE, // efi还原
};
explicit SystemRestoreProxy();
virtual ~SystemRestoreProxy();
public:
// 环境检测
virtual bool checkEnvEx();
// 任务处理
virtual void doWorkEx();
private:
// 还原efi
bool restoreEfi();
// 修复efi目录
void repairEfi();
// 同步efi
bool rsyncEfi();
// 系统还原
void restoreSystem();
// 删除home下的用户家目录
void removeHome(const QString& path);
// 获取备份点里存在家目录的用户列表
QStringList getBackupPointUsers();
QStringList getBackupPointUsers(const QString& path);
// 待还原数据
void undoRestoreData();
// 还原备份还原工具自身
void rsyncBackupSelf();
/**
* @brief 再一次同步
* @note 意图通过多次同步查缺补漏,如:
* 1、因为系统还原过程中~/.config等目录中的部分文件可能会更新会引起部分bug
* a. 配网,打开奇安信浏览器,触发自动更新(或者软件商店手动更新),且奇安信默认固定在任务栏;
* b. 下载安装微信固定任务栏新装任意第三方软件均可会删除desktop文件
* c. 上面两种操作都会触发任务栏配置更新通过监控任务栏配置文件在系统还原过程中可以明显的看到在还原1%的时候,配置文件还原到历史文件,桌面图标还原,然后下一秒配置文件就又更新成当前最新的了
*/
void rsyncAgain();
/**
* @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_bSuccess;
// 当前备份uuid
QString m_curUuid;
// 当前还原源目录
QString m_srcPath;
// 备份进程
RsyncPathToDirProcess *m_p;
// 当前备份节点
ParseBackupList::BackupPoint m_backupPoint;
// 是否保留用户数据
bool m_bRetainUserData;
};
#endif // SYSTEMRESTOREPROXY_H