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

98 lines
2.4 KiB
C
Raw Normal View History

2021-08-06 10:20:03 +08:00
#ifndef SYSTEMBACKUPPROXY_H
#define SYSTEMBACKUPPROXY_H
#include "workerfactory.h"
2022-01-18 17:35:26 +08:00
#include "myprocess/calcbackupsize.h"
2021-08-24 18:08:18 +08:00
#include "myprocess/rsyncpathtodirprocess.h"
#include "parsebackuplist.h"
2021-08-06 10:20:03 +08:00
class SystemBackupProxy : public Worker
{
Q_OBJECT
DECLARE_DYNCREATE(SystemBackupProxy)
public:
2021-08-17 10:07:35 +08:00
// 系统备份的几种场景
enum SystemBackupScene {
SYSTEM_BACKUP, // 系统备份
INC_SYSTEM_BACKUP, // 增量系统备份
2021-08-19 19:24:49 +08:00
INC_SYSTEM_BACKUP_AT_BASE, // 在原备份点里增量备份
2021-08-17 10:07:35 +08:00
TRY_SYSTEM_BACKUP, // 测试系统备份,可用于计算备份传输数据大小
TRY_INC_SYSTEM_BACKUP, // 测试增量系统备份,可用于计算备份传输数据大小
2021-08-19 19:24:49 +08:00
TRY_INC_SYSTEM_BACKUP_AT_BASE, // 测试增量系统备份,在原备份点里增量备份,可用于计算备份传输数据大小
2021-08-24 18:08:18 +08:00
EFI_BACKUP, // 备份/boot/efi
2021-08-17 10:07:35 +08:00
};
explicit SystemBackupProxy();
2021-08-06 10:20:03 +08:00
virtual ~SystemBackupProxy();
public:
// 环境检测
2021-08-24 18:08:18 +08:00
virtual bool checkEnvEx();
2021-08-06 10:20:03 +08:00
// 任务处理
virtual void doWorkEx();
// 任务取消
virtual void cancelEx();
2021-08-17 10:07:35 +08:00
private:
2021-08-24 18:08:18 +08:00
// 判断是否增量备份
bool isIncBackup();
2021-08-17 10:07:35 +08:00
// 校验剩余空间是否满足备份
2022-01-18 17:35:26 +08:00
void checkFreeCapacity(qint64 itotalSize);
2021-08-19 19:24:49 +08:00
// 计算备份所需空间大小
2022-01-18 17:35:26 +08:00
void calcSizeForBackup();
2021-08-17 10:07:35 +08:00
/**
* @brief rsync命令参数
* @param scene
* @return rsync的参数信息
*/
2021-08-19 19:24:49 +08:00
QStringList getRsyncArgs(SystemBackupScene scene);
2021-08-17 10:07:35 +08:00
/**
* @brief /backup/snapshots/backuplist.xml文件
* @return true-false-
*/
bool recordBackupPoint();
2021-08-24 18:08:18 +08:00
// 备份准备
bool doPrepare();
// 备份
void doBackup();
// 备份/boot/efi
bool backupEfi();
// 备份系统
bool backupSystem();
2022-01-18 17:35:26 +08:00
// 失败则删除相应数据
void deleteFailedData();
// 是否只是检测
bool m_isOnlyCheck;
2021-08-24 18:08:18 +08:00
// 是否备份成功
bool m_bSuccess;
2022-01-18 17:35:26 +08:00
// 是否完成
bool m_isFinished;
2021-08-24 18:08:18 +08:00
// 当前备份uuid
QString m_curUuid;
// 当前备份目标目录
QString m_destPath;
// 当前备份所需空间大小
qint64 m_size;
2022-01-18 17:35:26 +08:00
// 计算备份空间大小的进程
CalcBackupSize *m_calc;
2021-08-24 18:08:18 +08:00
// 备份进程
RsyncPathToDirProcess *m_p;
// 当前备份节点
ParseBackupList::BackupPoint m_backupPoint;
2021-08-24 18:08:18 +08:00
2021-08-06 10:20:03 +08:00
};
#endif // SYSTEMBACKUPPROXY_H