2021-12-26 18:15:21 +08:00
|
|
|
|
#ifndef DATABACKUPPROXY_H
|
|
|
|
|
#define DATABACKUPPROXY_H
|
|
|
|
|
|
|
|
|
|
#include "workerfactory.h"
|
2022-01-18 17:35:26 +08:00
|
|
|
|
#include "myprocess/calcbackupsize.h"
|
2021-12-26 18:15:21 +08:00
|
|
|
|
#include "myprocess/rsyncpathtodirprocess.h"
|
|
|
|
|
#include "parsebackuplist.h"
|
|
|
|
|
|
|
|
|
|
class DataBackupProxy : public Worker
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
DECLARE_DYNCREATE(DataBackupProxy)
|
|
|
|
|
public:
|
|
|
|
|
// 系统备份的几种场景
|
|
|
|
|
enum DataBackupScene {
|
|
|
|
|
DATA_BACKUP, // 系统备份
|
|
|
|
|
INC_DATA_BACKUP, // 增量系统备份
|
|
|
|
|
TRY_DATA_BACKUP, // 测试系统备份,可用于计算备份传输数据大小
|
|
|
|
|
TRY_INC_DATA_BACKUP, // 测试增量系统备份,可用于计算备份传输数据大小
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
explicit DataBackupProxy();
|
|
|
|
|
virtual ~DataBackupProxy();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// 环境检测
|
|
|
|
|
virtual bool checkEnvEx();
|
|
|
|
|
|
|
|
|
|
// 任务处理
|
|
|
|
|
virtual void doWorkEx();
|
|
|
|
|
|
2022-01-18 17:35:26 +08:00
|
|
|
|
public slots:
|
2021-12-26 18:15:21 +08:00
|
|
|
|
// 任务取消
|
|
|
|
|
virtual void cancelEx();
|
|
|
|
|
|
2022-01-18 17:35:26 +08:00
|
|
|
|
private slots:
|
2021-12-26 18:15:21 +08:00
|
|
|
|
// 校验剩余空间是否满足备份
|
2022-01-18 17:35:26 +08:00
|
|
|
|
bool checkFreeCapacity(qint64 itotalSize);
|
2021-12-26 18:15:21 +08:00
|
|
|
|
|
2022-01-18 17:35:26 +08:00
|
|
|
|
// 备份
|
|
|
|
|
void doBackup();
|
|
|
|
|
|
|
|
|
|
private:
|
2021-12-26 18:15:21 +08:00
|
|
|
|
// 计算备份所需空间大小
|
2022-01-18 17:35:26 +08:00
|
|
|
|
void calcSizeForBackup();
|
2021-12-26 18:15:21 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 记录/backup/snapshots/backuplist.xml文件
|
|
|
|
|
* @return true-成功;false-失败
|
|
|
|
|
*/
|
|
|
|
|
bool recordBackupPoint();
|
|
|
|
|
|
|
|
|
|
// 备份准备
|
|
|
|
|
bool doPrepare();
|
|
|
|
|
|
|
|
|
|
// 备份系统
|
|
|
|
|
bool backupData();
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
// 判断是否增量备份
|
|
|
|
|
bool isIncBackup();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 根据场景获取rsync命令参数
|
|
|
|
|
* @param scene,场景
|
|
|
|
|
* @return 组装好的rsync的参数信息
|
|
|
|
|
*/
|
|
|
|
|
QStringList getRsyncArgs(DataBackupScene scene);
|
|
|
|
|
|
|
|
|
|
void do_kylin_security(const QString& dstDir);
|
|
|
|
|
|
2022-01-18 17:35:26 +08:00
|
|
|
|
// 失败则删除相应数据
|
|
|
|
|
virtual void deleteFailedData();
|
|
|
|
|
|
|
|
|
|
// 计算备份空间大小的进程
|
|
|
|
|
CalcBackupSize *m_calc;
|
|
|
|
|
// 是否只是检测
|
|
|
|
|
bool m_isOnlyCheck;
|
2021-12-26 18:15:21 +08:00
|
|
|
|
// 是否完成
|
2022-01-18 17:35:26 +08:00
|
|
|
|
bool m_isFinished;
|
|
|
|
|
// 是否成功
|
2021-12-26 18:15:21 +08:00
|
|
|
|
bool m_bSuccess;
|
|
|
|
|
// 当前备份uuid
|
|
|
|
|
QString m_curUuid;
|
|
|
|
|
// 当前备份目标目录
|
|
|
|
|
QString m_destPath;
|
|
|
|
|
// 当前备份所需空间大小
|
|
|
|
|
qint64 m_size;
|
|
|
|
|
// 备份点用户备份路径文件
|
|
|
|
|
QString m_userFile;
|
|
|
|
|
// 备份点排除备份路径文件
|
|
|
|
|
QString m_excludeUserFile;
|
|
|
|
|
// 备份进程
|
|
|
|
|
RsyncPathToDirProcess *m_p;
|
|
|
|
|
// 当前备份节点
|
|
|
|
|
ParseBackupList::BackupPoint m_backupPoint;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // DATABACKUPPROXY_H
|