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

123 lines
2.9 KiB
C
Raw Normal View History

2021-11-11 16:03:58 +08:00
#ifndef UDISKSYSTEMBACKUPPROXY_H
#define UDISKSYSTEMBACKUPPROXY_H
#include "workerfactory.h"
2021-11-20 12:09:26 +08:00
#include "myprocess/calcbackupsize.h"
#include "myprocess/mksquashfsprocess.h"
2021-11-11 16:03:58 +08:00
#include "myprocess/rsyncpathtodirprocess.h"
#include "parsebackuplist.h"
class UDiskSystemBackupProxy : public Worker
{
Q_OBJECT
DECLARE_DYNCREATE(UDiskSystemBackupProxy)
public:
// 系统备份的几种场景
enum UDiskSystemBackupScene {
SYSTEM_BACKUP, // 系统备份
TRY_SYSTEM_BACKUP, // 测试系统备份,可用于计算备份传输数据大小
2021-11-20 12:09:26 +08:00
MKSQUASHFS, // 生成img文件
IMG_BACKUP, // 备份img文件
2021-11-11 16:03:58 +08:00
};
explicit UDiskSystemBackupProxy();
virtual ~UDiskSystemBackupProxy();
public:
// 环境检测
virtual bool checkEnvEx();
// 任务处理
virtual void doWorkEx();
2021-11-20 12:09:26 +08:00
signals:
2021-11-11 16:03:58 +08:00
private slots:
// 校验剩余空间是否满足备份
void checkFreeCapacity(qint64 itotalSize);
2021-11-20 12:09:26 +08:00
// mksqushfs
void doMksqushfs();
// 备份
void doBackup();
2022-01-18 17:35:26 +08:00
// 任务取消
virtual void cancelEx();
2021-12-26 18:15:21 +08:00
/**
* @brief
* @return: bool,truefalse
* @author: zhaominyong
* @since: 2021/05/24
* @note:
* add by zhaominyong at 2021/05/24 for bug:54377 U盘的过程中拔出U盘
*/
bool checkDestDirExists();
2021-11-11 16:03:58 +08:00
private:
// 判断是否增量备份
bool isIncBackup();
// 计算备份所需空间大小
void calcSizeForBackup();
/**
* @brief rsync命令参数
* @param scene
* @return rsync的参数信息
*/
QStringList getRsyncArgs(UDiskSystemBackupScene scene);
/**
* @brief /backup/snapshots/backuplist.xml文件
* @return true-false-
*/
bool recordBackupPoint();
// 备份准备
bool doPrepare();
// 备份系统
bool backupSystem();
2021-11-20 12:09:26 +08:00
// 备份img文件
bool backupImg();
bool backup(const QStringList &args);
2021-11-11 16:03:58 +08:00
void do_kylin_security(const QString& dstDir);
2022-01-18 17:35:26 +08:00
// 失败则删除相应数据
void deleteFailedData();
2021-11-11 16:03:58 +08:00
// 计算备份空间大小的进程
CalcBackupSize *m_calc;
2021-11-20 12:09:26 +08:00
// 压缩进程
MkSquashFSProcess *m_mksquashfs;
2021-11-11 16:03:58 +08:00
2021-12-26 18:15:21 +08:00
// 是否完成
bool m_isFinished;
2021-11-11 16:03:58 +08:00
// 是否备份成功
bool m_bSuccess;
// 当前备份uuid
QString m_curUuid;
// 当前备份目标目录
QString m_destPath;
// 当前备份所需空间大小
qint64 m_size;
// 备份进程
RsyncPathToDirProcess *m_p;
// 当前备份节点
ParseBackupList::BackupPoint m_backupPoint;
// 是否只是检测
bool m_isOnlyCheck;
2021-11-20 12:09:26 +08:00
// img文件存放路径
QString m_imgPath;
// 强制结束标志(stop后没反应的情况系统处于睡眠状态)
bool m_isForce;
2021-11-11 16:03:58 +08:00
};
#endif // UDISKSYSTEMBACKUPPROXY_H