ghost image
This commit is contained in:
parent
aae6b39ca7
commit
b6eaa43087
|
@ -34,6 +34,7 @@ HEADERS += \
|
||||||
databackupproxy.h \
|
databackupproxy.h \
|
||||||
datarestoreproxy.h \
|
datarestoreproxy.h \
|
||||||
deletebackupproxy.h \
|
deletebackupproxy.h \
|
||||||
|
ghostimageproxy.h \
|
||||||
mybackupmanager.h \
|
mybackupmanager.h \
|
||||||
mymountproxy.h \
|
mymountproxy.h \
|
||||||
myprocess/calcbackupsize.h \
|
myprocess/calcbackupsize.h \
|
||||||
|
@ -46,6 +47,7 @@ HEADERS += \
|
||||||
systemrestoreproxy.h \
|
systemrestoreproxy.h \
|
||||||
udiskdatabackupproxy.h \
|
udiskdatabackupproxy.h \
|
||||||
udiskdatarestoreproxy.h \
|
udiskdatarestoreproxy.h \
|
||||||
|
udiskghostImageproxy.h \
|
||||||
udisksystembackupproxy.h \
|
udisksystembackupproxy.h \
|
||||||
udisksystemrestoreproxy.h \
|
udisksystemrestoreproxy.h \
|
||||||
workerfactory.h
|
workerfactory.h
|
||||||
|
@ -60,6 +62,7 @@ SOURCES += \
|
||||||
databackupproxy.cpp \
|
databackupproxy.cpp \
|
||||||
datarestoreproxy.cpp \
|
datarestoreproxy.cpp \
|
||||||
deletebackupproxy.cpp \
|
deletebackupproxy.cpp \
|
||||||
|
ghostimageproxy.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
mybackupmanager.cpp \
|
mybackupmanager.cpp \
|
||||||
mymountproxy.cpp \
|
mymountproxy.cpp \
|
||||||
|
@ -73,6 +76,7 @@ SOURCES += \
|
||||||
systemrestoreproxy.cpp \
|
systemrestoreproxy.cpp \
|
||||||
udiskdatabackupproxy.cpp \
|
udiskdatabackupproxy.cpp \
|
||||||
udiskdatarestoreproxy.cpp \
|
udiskdatarestoreproxy.cpp \
|
||||||
|
udiskghostImageproxy.cpp \
|
||||||
udisksystembackupproxy.cpp \
|
udisksystembackupproxy.cpp \
|
||||||
udisksystemrestoreproxy.cpp \
|
udisksystemrestoreproxy.cpp \
|
||||||
workerfactory.cpp
|
workerfactory.cpp
|
||||||
|
|
|
@ -106,7 +106,7 @@ bool DataBackupProxy::checkFreeCapacity()
|
||||||
QString backupPath(Utils::getSysRootPath() + BACKUP_PATH);
|
QString backupPath(Utils::getSysRootPath() + BACKUP_PATH);
|
||||||
backupPath.replace("//", "/");
|
backupPath.replace("//", "/");
|
||||||
QStorageInfo backupDisk(backupPath);
|
QStorageInfo backupDisk(backupPath);
|
||||||
qint64 freeSize = backupDisk.bytesFree();
|
qint64 freeSize = backupDisk.bytesAvailable();
|
||||||
|
|
||||||
// 3、校验空间是否足够
|
// 3、校验空间是否足够
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
|
@ -0,0 +1,127 @@
|
||||||
|
#include "ghostimageproxy.h"
|
||||||
|
#include <QStorageInfo>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <kysec/status.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "../common/utils.h"
|
||||||
|
#include "../common/mydusizetool.h"
|
||||||
|
#include "mymountproxy.h"
|
||||||
|
#include "myprocess/calcbackupsize.h"
|
||||||
|
|
||||||
|
IMPLEMENT_DYNCREATE(GhostImageProxy)
|
||||||
|
|
||||||
|
GhostImageProxy::GhostImageProxy()
|
||||||
|
{
|
||||||
|
m_mksquashfs = nullptr;
|
||||||
|
m_bSuccess = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
GhostImageProxy::~GhostImageProxy()
|
||||||
|
{
|
||||||
|
delete m_mksquashfs;
|
||||||
|
m_mksquashfs = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 环境检测
|
||||||
|
*/
|
||||||
|
bool GhostImageProxy::checkEnvEx()
|
||||||
|
{
|
||||||
|
// 1、检查/backup分区是否挂载上(不管是本地磁盘还是u盘设备,都得保证/backup挂载上); 若没挂载,挂载
|
||||||
|
MyMountProxy mountProxy;
|
||||||
|
if ( MountResult::MOUNTED != mountProxy.mountBackupPartition() ) {
|
||||||
|
emit checkResult(int(BackupResult::BACKUP_PARTITION_MOUNT_FAIL));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2、校验backuppoint.xml中相应的备份节点是否存在
|
||||||
|
QString xmlPath = Utils::getSysRootPath() + BACKUP_XML_PATH;
|
||||||
|
xmlPath.replace("//", "/");
|
||||||
|
ParseBackupList xmlParse(xmlPath);
|
||||||
|
ParseBackupList::BackupPoint backupPoint = xmlParse.findBackupPointByUuid(m_backupWrapper.m_uuid);
|
||||||
|
if (backupPoint.m_backupName.isEmpty()) {
|
||||||
|
emit checkResult(int(BackupResult::GHOST_CANNOT_FIND_BACKUPPOINT));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3、校验备份数据是否存在
|
||||||
|
QString dataPath = Utils::getSysRootPath() + BACKUP_SNAPSHOTS_PATH + "/" + m_backupWrapper.m_uuid + "/data";
|
||||||
|
dataPath.replace("//", "/");
|
||||||
|
if (Utils::isDirEmpty(dataPath)) {
|
||||||
|
emit checkResult(int(BackupResult::GHOST_SRC_DIRECTORY_IS_NOT_EXIST));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
QFileInfo backup(dataPath);
|
||||||
|
qint64 itotalSize = backup.size();
|
||||||
|
|
||||||
|
// 4、校验空间大小是否充足
|
||||||
|
m_destPath = Utils::getSysRootPath() + GHOST_PATH;
|
||||||
|
m_destPath.replace("//", "/");
|
||||||
|
Utils::mkpath(m_destPath);
|
||||||
|
m_kyimg = Utils::getSysRootPath() + GHOST_PATH + "/" + m_backupWrapper.m_backupName;
|
||||||
|
m_kyimg.replace("//", "/");
|
||||||
|
QFile kyimg(m_kyimg);
|
||||||
|
if (kyimg.exists())
|
||||||
|
kyimg.remove();
|
||||||
|
QStorageInfo storageInfo(m_destPath);
|
||||||
|
qint64 sizeAvailable = storageInfo.bytesAvailable();
|
||||||
|
if (sizeAvailable < itotalSize / 2) {
|
||||||
|
emit checkResult(int(BackupResult::BACKUP_CAPACITY_IS_NOT_ENOUGH));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit checkResult(int(BackupResult::CHECK_ENV_SUCCESS));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 任务处理
|
||||||
|
*/
|
||||||
|
void GhostImageProxy::doWorkEx()
|
||||||
|
{
|
||||||
|
if (!checkEnvEx())
|
||||||
|
return ;
|
||||||
|
|
||||||
|
doGhostImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 任务取消
|
||||||
|
*/
|
||||||
|
void GhostImageProxy::cancelEx()
|
||||||
|
{}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ghost镜像
|
||||||
|
*/
|
||||||
|
void GhostImageProxy::doGhostImage()
|
||||||
|
{
|
||||||
|
QStringList args;
|
||||||
|
// 拼接备份源路径和目标路径
|
||||||
|
QString srcPath = Utils::getSysRootPath() + BACKUP_SNAPSHOTS_PATH + "/" + m_backupWrapper.m_uuid + "/data";
|
||||||
|
srcPath.replace("//", "/");
|
||||||
|
args << srcPath;
|
||||||
|
args << m_kyimg;
|
||||||
|
|
||||||
|
m_mksquashfs = new MkSquashFSProcess(this);
|
||||||
|
connect(m_mksquashfs, &MkSquashFSProcess::progress, this, &GhostImageProxy::progress);
|
||||||
|
connect(m_mksquashfs, &MkSquashFSProcess::finished, this, [&](bool result) {
|
||||||
|
if (result) {
|
||||||
|
chown(m_kyimg.toLocal8Bit().data(), m_backupWrapper.m_frontUid, m_backupWrapper.m_gid);
|
||||||
|
QFileInfo fileInfo(m_kyimg);
|
||||||
|
QString imgSize = Utils::StringBySize(fileInfo.size());
|
||||||
|
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
|
||||||
|
Utils::writeBackupLog(time + ","
|
||||||
|
+ m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ","
|
||||||
|
+ m_backupWrapper.m_note + "," + imgSize
|
||||||
|
+ ",," + m_backupWrapper.m_backupName);
|
||||||
|
m_bSuccess = true;
|
||||||
|
}
|
||||||
|
emit this->workResult(result);
|
||||||
|
});
|
||||||
|
m_bSuccess = false;
|
||||||
|
m_mksquashfs->start(args);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
#ifndef GHOSTIMAGEPROXY_H
|
||||||
|
#define GHOSTIMAGEPROXY_H
|
||||||
|
|
||||||
|
#include "workerfactory.h"
|
||||||
|
#include "myprocess/mksquashfsprocess.h"
|
||||||
|
#include "myprocess/rsyncpathtodirprocess.h"
|
||||||
|
#include "parsebackuplist.h"
|
||||||
|
|
||||||
|
class GhostImageProxy : public Worker
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
DECLARE_DYNCREATE(GhostImageProxy)
|
||||||
|
public:
|
||||||
|
explicit GhostImageProxy();
|
||||||
|
virtual ~GhostImageProxy();
|
||||||
|
|
||||||
|
public:
|
||||||
|
// 环境检测
|
||||||
|
virtual bool checkEnvEx();
|
||||||
|
|
||||||
|
// 任务处理
|
||||||
|
virtual void doWorkEx();
|
||||||
|
|
||||||
|
// 任务取消
|
||||||
|
virtual void cancelEx();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void doGhostImage();
|
||||||
|
|
||||||
|
// 存放.kyimg文件的目录
|
||||||
|
QString m_destPath;
|
||||||
|
// .kyimg文件
|
||||||
|
QString m_kyimg;
|
||||||
|
|
||||||
|
// 压缩进程
|
||||||
|
MkSquashFSProcess *m_mksquashfs;
|
||||||
|
|
||||||
|
// 是否成功
|
||||||
|
bool m_bSuccess;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GHOSTIMAGEPROXY_H
|
|
@ -245,8 +245,48 @@ int MyBackupManager::deleteBackupPoint(const BackupWrapper& backupWrapper)
|
||||||
*/
|
*/
|
||||||
int MyBackupManager::ghostBackup(const BackupWrapper& backupWrapper)
|
int MyBackupManager::ghostBackup(const BackupWrapper& backupWrapper)
|
||||||
{
|
{
|
||||||
Q_UNUSED(backupWrapper)
|
qDebug("MyBackupManager::ghostBackup invoke begin");
|
||||||
return 0;
|
if (m_isActive || !lock(backupWrapper.m_frontUid)) {
|
||||||
|
emit sendEnvCheckResult(int(BackupResult::LOCK_PROGRAM_FAIL));
|
||||||
|
return int(BackupResult::LOCK_PROGRAM_FAIL);
|
||||||
|
}
|
||||||
|
|
||||||
|
Worker* worker = WorkerFactory::createWorker(backupWrapper.m_type, backupWrapper.m_iPosition);
|
||||||
|
if (nullptr == worker) {
|
||||||
|
emit sendEnvCheckResult(int(BackupResult::NO_FOUND_DEALCLASS));
|
||||||
|
return int(BackupResult::NO_FOUND_DEALCLASS);
|
||||||
|
}
|
||||||
|
|
||||||
|
worker->setParam(backupWrapper);
|
||||||
|
connect(worker, &Worker::checkResult, this, [&](int result) {
|
||||||
|
emit this->sendEnvCheckResult(result);
|
||||||
|
|
||||||
|
switch (result) {
|
||||||
|
case int(BackupResult::CHECK_ENV_SUCCESS) :
|
||||||
|
case int(BackupResult::MKSQUASHFS_START_SUCCESS) :
|
||||||
|
case int(BackupResult::GHOST_START_SUCCESS) :
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this->finished();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connect(worker, &Worker::progress, this, [&](int rate) {
|
||||||
|
emit this->progress(int(BackupState::WORKING), rate);
|
||||||
|
});
|
||||||
|
connect(worker, &Worker::workResult, this, [&] (bool result) {
|
||||||
|
emit this->sendGhostBackupResult(result);
|
||||||
|
this->finished();
|
||||||
|
});
|
||||||
|
worker->moveToThread(&workerThread);
|
||||||
|
connect(&workerThread, &MyThread::started, worker, &Worker::doWork);
|
||||||
|
connect(&workerThread, &MyThread::finished, worker, &Worker::deleteLater);
|
||||||
|
connect(&workerThread, &MyThread::cancelWork, worker, &Worker::cancel);
|
||||||
|
|
||||||
|
workerThread.start();
|
||||||
|
|
||||||
|
qDebug("MyBackupManager::ghostBackup invoke end");
|
||||||
|
return int(BackupResult::BACKUP_RESULT_INIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -113,7 +113,7 @@ bool SystemBackupProxy::checkFreeCapacity()
|
||||||
QString backupPath(Utils::getSysRootPath() + BACKUP_PATH);
|
QString backupPath(Utils::getSysRootPath() + BACKUP_PATH);
|
||||||
backupPath.replace("//", "/");
|
backupPath.replace("//", "/");
|
||||||
QStorageInfo backupDisk(backupPath);
|
QStorageInfo backupDisk(backupPath);
|
||||||
qint64 freeSize = backupDisk.bytesFree();
|
qint64 freeSize = backupDisk.bytesAvailable();
|
||||||
|
|
||||||
// 3、校验空间是否足够
|
// 3、校验空间是否足够
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
|
@ -105,7 +105,7 @@ bool UDiskDataBackupProxy::checkFreeCapacityToUdisk(qint64 itotalSize)
|
||||||
QString backupPath(m_backupWrapper.m_prefixDestPath);
|
QString backupPath(m_backupWrapper.m_prefixDestPath);
|
||||||
backupPath.replace("//", "/");
|
backupPath.replace("//", "/");
|
||||||
QStorageInfo backupDisk(backupPath);
|
QStorageInfo backupDisk(backupPath);
|
||||||
qint64 freeSize = backupDisk.bytesFree();
|
qint64 freeSize = backupDisk.bytesAvailable();
|
||||||
|
|
||||||
// 3、校验空间是否足够
|
// 3、校验空间是否足够
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
|
@ -0,0 +1,221 @@
|
||||||
|
#include "udiskghostImageproxy.h"
|
||||||
|
#include <QStorageInfo>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <kysec/status.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "../common/utils.h"
|
||||||
|
#include "../common/mydusizetool.h"
|
||||||
|
#include "mymountproxy.h"
|
||||||
|
#include "myprocess/calcbackupsize.h"
|
||||||
|
|
||||||
|
IMPLEMENT_DYNCREATE(UDiskGhostImageProxy)
|
||||||
|
|
||||||
|
UDiskGhostImageProxy::UDiskGhostImageProxy()
|
||||||
|
{
|
||||||
|
m_mksquashfs = nullptr;
|
||||||
|
m_p = nullptr;
|
||||||
|
m_bSuccess = false;
|
||||||
|
m_isFinished = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
UDiskGhostImageProxy::~UDiskGhostImageProxy()
|
||||||
|
{
|
||||||
|
if (!m_kyimg.isEmpty()) {
|
||||||
|
QFile kyimg(m_kyimg);
|
||||||
|
if (kyimg.exists())
|
||||||
|
kyimg.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 环境检测
|
||||||
|
*/
|
||||||
|
bool UDiskGhostImageProxy::checkEnvEx()
|
||||||
|
{
|
||||||
|
// 1、检查/backup分区是否挂载上(不管是本地磁盘还是u盘设备,都得保证/backup挂载上); 若没挂载,挂载
|
||||||
|
MyMountProxy mountProxy;
|
||||||
|
if ( MountResult::MOUNTED != mountProxy.mountBackupPartition() ) {
|
||||||
|
emit checkResult(int(BackupResult::BACKUP_PARTITION_MOUNT_FAIL));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2、校验backuppoint.xml中相应的备份节点是否存在
|
||||||
|
QString xmlPath = Utils::getSysRootPath() + BACKUP_XML_PATH;
|
||||||
|
xmlPath.replace("//", "/");
|
||||||
|
ParseBackupList xmlParse(xmlPath);
|
||||||
|
ParseBackupList::BackupPoint backupPoint = xmlParse.findBackupPointByUuid(m_backupWrapper.m_uuid);
|
||||||
|
if (backupPoint.m_backupName.isEmpty()) {
|
||||||
|
emit checkResult(int(BackupResult::GHOST_CANNOT_FIND_BACKUPPOINT));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3、校验备份数据是否存在
|
||||||
|
QString dataPath = Utils::getSysRootPath() + BACKUP_SNAPSHOTS_PATH + "/" + m_backupWrapper.m_uuid + "/data";
|
||||||
|
dataPath.replace("//", "/");
|
||||||
|
if (Utils::isDirEmpty(dataPath)) {
|
||||||
|
emit checkResult(int(BackupResult::GHOST_SRC_DIRECTORY_IS_NOT_EXIST));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
QFileInfo backup(dataPath);
|
||||||
|
qint64 itotalSize = backup.size();
|
||||||
|
|
||||||
|
// 4、校验移动设备情况:空间大小、文件格式、挂载模式等
|
||||||
|
QString backupPath(m_backupWrapper.m_prefixDestPath);
|
||||||
|
backupPath.replace("//", "/");
|
||||||
|
QStorageInfo udisk(backupPath);
|
||||||
|
QString udisk_type = udisk.fileSystemType();
|
||||||
|
if (udisk_type == "vfat") {
|
||||||
|
qCritical() << m_backupWrapper.m_prefixDestPath + " udisk's filesystemtype is vfat";
|
||||||
|
emit checkResult(int(BackupResult::UDISK_FILESYSTEM_TYPE_IS_VFAT));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (udisk.isReadOnly()) {
|
||||||
|
// 只读挂载的U盘
|
||||||
|
qCritical() << QString("udisk(%s) is readonly filesystem").arg(m_backupWrapper.m_prefixDestPath);
|
||||||
|
emit checkResult(int(BackupResult::UDISK_FILESYSTEM_IS_READONLY));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_destPath = m_backupWrapper.m_prefixDestPath + GHOST_PATH;
|
||||||
|
m_destPath.replace("//", "/");
|
||||||
|
Utils::mkpath(m_destPath);
|
||||||
|
m_kyimg = Utils::getSysRootPath() + GHOST_PATH + "/" + m_backupWrapper.m_backupName;
|
||||||
|
m_kyimg.replace("//", "/");
|
||||||
|
QFile kyimg(m_kyimg);
|
||||||
|
if (kyimg.exists())
|
||||||
|
kyimg.remove();
|
||||||
|
QStorageInfo storageInfo(m_destPath);
|
||||||
|
qint64 sizeAvailable = storageInfo.bytesAvailable();
|
||||||
|
if (sizeAvailable < itotalSize / 2) {
|
||||||
|
emit checkResult(int(BackupResult::BACKUP_CAPACITY_IS_NOT_ENOUGH));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5、依托本地存储先行压缩再拷贝到移动设备,在此查找空闲分区临时借用
|
||||||
|
bool found = false;
|
||||||
|
QHash<QString, qint64> hash = Utils::getAvailableSizeOfPartitions();
|
||||||
|
for (QHash<QString, qint64>::const_iterator it = hash.constBegin(); it != hash.constEnd(); ++it) {
|
||||||
|
QString path = it.key();
|
||||||
|
qint64 leftSize = it.value();
|
||||||
|
if (itotalSize < leftSize / 2) {
|
||||||
|
m_kyimg = path + GHOST_PATH + "/" + m_backupWrapper.m_backupName;
|
||||||
|
m_kyimg.replace("//", "/");
|
||||||
|
QFile kyimg(m_kyimg);
|
||||||
|
if (kyimg.exists())
|
||||||
|
kyimg.remove();
|
||||||
|
|
||||||
|
found = true;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
emit checkResult(int(BackupResult::BACKUP_CAPACITY_FOR_UDISKIMG_IS_NOT_ENOUGH));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit checkResult(int(BackupResult::CHECK_ENV_SUCCESS));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 任务处理
|
||||||
|
*/
|
||||||
|
void UDiskGhostImageProxy::doWorkEx()
|
||||||
|
{
|
||||||
|
if (!checkEnvEx())
|
||||||
|
return ;
|
||||||
|
|
||||||
|
doGhostImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 任务取消
|
||||||
|
*/
|
||||||
|
void UDiskGhostImageProxy::cancelEx()
|
||||||
|
{}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ghost镜像
|
||||||
|
*/
|
||||||
|
void UDiskGhostImageProxy::doGhostImage()
|
||||||
|
{
|
||||||
|
QStringList args;
|
||||||
|
// 拼接备份源路径和目标路径
|
||||||
|
QString srcPath = Utils::getSysRootPath() + BACKUP_SNAPSHOTS_PATH + "/" + m_backupWrapper.m_uuid + "/data";
|
||||||
|
srcPath.replace("//", "/");
|
||||||
|
args << srcPath;
|
||||||
|
args << m_kyimg;
|
||||||
|
|
||||||
|
m_mksquashfs = new MkSquashFSProcess(this);
|
||||||
|
connect(m_mksquashfs, &MkSquashFSProcess::progress, this, &UDiskGhostImageProxy::progress);
|
||||||
|
connect(m_mksquashfs, &MkSquashFSProcess::finished, this, [&](bool result) {
|
||||||
|
if (result) {
|
||||||
|
chown(m_kyimg.toLocal8Bit().data(), m_backupWrapper.m_frontUid, m_backupWrapper.m_gid);
|
||||||
|
|
||||||
|
// 同步到U盘
|
||||||
|
m_p = new RsyncPathToDirProcess(this);
|
||||||
|
connect(m_p, &RsyncPathToDirProcess::finished, this, [&](bool resultRsync) {
|
||||||
|
m_isFinished = true;
|
||||||
|
if (resultRsync) {
|
||||||
|
QFileInfo fileInfo(m_kyimg);
|
||||||
|
QString imgSize = Utils::StringBySize(fileInfo.size());
|
||||||
|
QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss");
|
||||||
|
Utils::writeBackupLog(time + ","
|
||||||
|
+ m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ","
|
||||||
|
+ m_backupWrapper.m_note + "," + imgSize
|
||||||
|
+ ",," + m_backupWrapper.m_backupName);
|
||||||
|
m_bSuccess = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit this->workResult(resultRsync);
|
||||||
|
});
|
||||||
|
|
||||||
|
QStringList arguments;
|
||||||
|
arguments << "-a";
|
||||||
|
arguments << m_kyimg;
|
||||||
|
arguments << m_destPath + "/";
|
||||||
|
m_p->start(arguments, false);
|
||||||
|
} else {
|
||||||
|
m_isFinished = true;
|
||||||
|
emit this->workResult(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
m_bSuccess = false;
|
||||||
|
m_isFinished = false;
|
||||||
|
m_mksquashfs->start(args);
|
||||||
|
QTimer::singleShot(1*1000, this, &UDiskGhostImageProxy::checkDestDirExists);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 校验移动盘是否还在
|
||||||
|
* @return: bool,存在返回true;不存在返回false
|
||||||
|
* @author: zhaominyong
|
||||||
|
* @since: 2021/05/24
|
||||||
|
* @note:
|
||||||
|
* add by zhaominyong at 2021/05/24 for bug:54377 【备份还原】备份数据到U盘的过程中拔出U盘,备份还原工具仍然一直显示正在备份数据
|
||||||
|
*/
|
||||||
|
bool UDiskGhostImageProxy::checkDestDirExists()
|
||||||
|
{
|
||||||
|
QDir dir(m_backupWrapper.m_prefixDestPath);
|
||||||
|
if (!dir.exists()) {
|
||||||
|
qCritical() << QString("dstDir %s is not exist!").arg(m_backupWrapper.m_prefixDestPath);
|
||||||
|
|
||||||
|
if (m_mksquashfs)
|
||||||
|
m_mksquashfs->stop();
|
||||||
|
if (m_p)
|
||||||
|
m_p->stop();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_isFinished)
|
||||||
|
{
|
||||||
|
QTimer::singleShot(1*1000, this, &UDiskGhostImageProxy::checkDestDirExists);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
#ifndef UDISKGHOSTIMAGEPROXY_H
|
||||||
|
#define UDISKGHOSTIMAGEPROXY_H
|
||||||
|
|
||||||
|
#include "workerfactory.h"
|
||||||
|
#include "myprocess/mksquashfsprocess.h"
|
||||||
|
#include "myprocess/rsyncpathtodirprocess.h"
|
||||||
|
#include "parsebackuplist.h"
|
||||||
|
|
||||||
|
class UDiskGhostImageProxy : public Worker
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
DECLARE_DYNCREATE(UDiskGhostImageProxy)
|
||||||
|
public:
|
||||||
|
explicit UDiskGhostImageProxy();
|
||||||
|
virtual ~UDiskGhostImageProxy();
|
||||||
|
|
||||||
|
public:
|
||||||
|
// 环境检测
|
||||||
|
virtual bool checkEnvEx();
|
||||||
|
|
||||||
|
// 任务处理
|
||||||
|
virtual void doWorkEx();
|
||||||
|
|
||||||
|
// 任务取消
|
||||||
|
virtual void cancelEx();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void doGhostImage();
|
||||||
|
bool checkDestDirExists();
|
||||||
|
|
||||||
|
// 存放.kyimg文件的目录
|
||||||
|
QString m_destPath;
|
||||||
|
// .kyimg文件
|
||||||
|
QString m_kyimg;
|
||||||
|
|
||||||
|
// 压缩进程
|
||||||
|
MkSquashFSProcess *m_mksquashfs;
|
||||||
|
// 备份进程
|
||||||
|
RsyncPathToDirProcess *m_p;
|
||||||
|
|
||||||
|
// 是否成功
|
||||||
|
bool m_bSuccess;
|
||||||
|
// 是否结束
|
||||||
|
bool m_isFinished;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // UDISKGHOSTIMAGEPROXY_H
|
|
@ -141,7 +141,7 @@ void UDiskSystemBackupProxy::checkFreeCapacity(qint64 itotalSize)
|
||||||
QString backupPath(m_backupWrapper.m_prefixDestPath);
|
QString backupPath(m_backupWrapper.m_prefixDestPath);
|
||||||
backupPath.replace("//", "/");
|
backupPath.replace("//", "/");
|
||||||
QStorageInfo backupDisk(backupPath);
|
QStorageInfo backupDisk(backupPath);
|
||||||
qint64 freeSize = backupDisk.bytesFree();
|
qint64 freeSize = backupDisk.bytesAvailable();
|
||||||
|
|
||||||
// 3、校验空间是否足够
|
// 3、校验空间是否足够
|
||||||
if (itotalSize > freeSize) {
|
if (itotalSize > freeSize) {
|
||||||
|
|
|
@ -93,9 +93,9 @@ Worker * WorkerFactory::createWorker(int type, int position)
|
||||||
break;
|
break;
|
||||||
case BackupType::GHOST_IMAGE:
|
case BackupType::GHOST_IMAGE:
|
||||||
if (BackupPosition::UDISK == position) {
|
if (BackupPosition::UDISK == position) {
|
||||||
className = "UDiskGhostProxy";
|
className = "UDiskGhostImageProxy";
|
||||||
} else {
|
} else {
|
||||||
className = "GhostProxy";
|
className = "GhostImageProxy";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#define IMGBACKUP_PATH "/imgbackup"
|
#define IMGBACKUP_PATH "/imgbackup"
|
||||||
#define UDISK_MKSQUASHFS_IMG_NAME "dst.img"
|
#define UDISK_MKSQUASHFS_IMG_NAME "dst.img"
|
||||||
#define UDISK_UNIQUE_SETTINGS "/backup/udisk_unique_file"
|
#define UDISK_UNIQUE_SETTINGS "/backup/udisk_unique_file"
|
||||||
|
#define GHOST_PATH "/ghost"
|
||||||
|
|
||||||
#define DATA_PATH "/data"
|
#define DATA_PATH "/data"
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QStorageInfo>
|
||||||
|
|
||||||
#include "mylittleparse.h"
|
#include "mylittleparse.h"
|
||||||
#include "mydefine.h"
|
#include "mydefine.h"
|
||||||
|
@ -1061,6 +1062,26 @@ QHash<QString, QString> Utils::getLeftSizeOfPartitions()
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 获取分区可用大小,主要是/和/data分区
|
||||||
|
* @return 路径和大小(单位:字节)键值对
|
||||||
|
*/
|
||||||
|
QHash<QString, qint64> Utils::getAvailableSizeOfPartitions()
|
||||||
|
{
|
||||||
|
QHash<QString, qint64> hash;
|
||||||
|
|
||||||
|
QString root = Utils::getSysRootPath();
|
||||||
|
QStorageInfo rootInfo(root);
|
||||||
|
hash.insert(root, rootInfo.bytesAvailable());
|
||||||
|
|
||||||
|
QString data = Utils::getSysRootPath() + DATA_PATH;
|
||||||
|
data.replace("//", "/");
|
||||||
|
QStorageInfo dataInfo(data);
|
||||||
|
hash.insert(data, dataInfo.bytesAvailable());
|
||||||
|
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 获取文件夹或文件的大小
|
* @brief 获取文件夹或文件的大小
|
||||||
* @param path 路径
|
* @param path 路径
|
||||||
|
@ -1140,3 +1161,5 @@ void Utils::wait(uint sec)
|
||||||
QTimer::singleShot(1000 * sec, &loop, SLOT(quit()));
|
QTimer::singleShot(1000 * sec, &loop, SLOT(quit()));
|
||||||
loop.exec();
|
loop.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -267,6 +267,12 @@ public:
|
||||||
*/
|
*/
|
||||||
static QHash<QString, QString> getLeftSizeOfPartitions();
|
static QHash<QString, QString> getLeftSizeOfPartitions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 获取分区可用大小,主要是/和/data分区
|
||||||
|
* @return 路径和大小(单位:字节)键值对
|
||||||
|
*/
|
||||||
|
static QHash<QString, qint64> getAvailableSizeOfPartitions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 获取文件夹或文件的大小
|
* @brief 获取文件夹或文件的大小
|
||||||
* @param path 路径
|
* @param path 路径
|
||||||
|
|
|
@ -32,5 +32,6 @@
|
||||||
<file alias="/symbos/ukui-dialog-success.png">resource/symbos/ukui-dialog-success.png</file>
|
<file alias="/symbos/ukui-dialog-success.png">resource/symbos/ukui-dialog-success.png</file>
|
||||||
<file alias="/images/empty.png">resource/images/empty.png</file>
|
<file alias="/images/empty.png">resource/images/empty.png</file>
|
||||||
<file alias="/images/empty_dark.png">resource/images/empty_dark.png</file>
|
<file alias="/images/empty_dark.png">resource/images/empty_dark.png</file>
|
||||||
|
<file alias="/symbos/document-open-recent-symbolic.png">resource/symbos/document-open-recent-symbolic.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -61,6 +61,7 @@ HEADERS += \
|
||||||
messageboxutils.h \
|
messageboxutils.h \
|
||||||
module/databackup.h \
|
module/databackup.h \
|
||||||
module/datarestore.h \
|
module/datarestore.h \
|
||||||
|
module/ghostimage.h \
|
||||||
module/managebackuppointlist.h \
|
module/managebackuppointlist.h \
|
||||||
module/operationlog.h \
|
module/operationlog.h \
|
||||||
module/selectrestorepoint.h \
|
module/selectrestorepoint.h \
|
||||||
|
@ -102,6 +103,7 @@ SOURCES += \
|
||||||
messageboxutils.cpp \
|
messageboxutils.cpp \
|
||||||
module/databackup.cpp \
|
module/databackup.cpp \
|
||||||
module/datarestore.cpp \
|
module/datarestore.cpp \
|
||||||
|
module/ghostimage.cpp \
|
||||||
module/managebackuppointlist.cpp \
|
module/managebackuppointlist.cpp \
|
||||||
module/operationlog.cpp \
|
module/operationlog.cpp \
|
||||||
module/selectrestorepoint.cpp \
|
module/selectrestorepoint.cpp \
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "module/databackup.h"
|
#include "module/databackup.h"
|
||||||
#include "module/datarestore.h"
|
#include "module/datarestore.h"
|
||||||
#include "module/operationlog.h"
|
#include "module/operationlog.h"
|
||||||
|
#include "module/ghostimage.h"
|
||||||
#include "backup_manager_interface.h"
|
#include "backup_manager_interface.h"
|
||||||
#include "globalbackupinfo.h"
|
#include "globalbackupinfo.h"
|
||||||
#include "messageboxutils.h"
|
#include "messageboxutils.h"
|
||||||
|
@ -227,6 +228,10 @@ void MainDialog::selected(int func_type)
|
||||||
m_stackedWidget = new OperationLog(ui->centralwidget);
|
m_stackedWidget = new OperationLog(ui->centralwidget);
|
||||||
GlobelBackupInfo::inst().setFuncType(FuncTypeConverter::FunType::OPERATION_LOG);
|
GlobelBackupInfo::inst().setFuncType(FuncTypeConverter::FunType::OPERATION_LOG);
|
||||||
break;
|
break;
|
||||||
|
case FuncTypeConverter::FunType::GHOST_IMAGE:
|
||||||
|
m_stackedWidget = new GhostImage(ui->centralwidget);
|
||||||
|
GlobelBackupInfo::inst().setFuncType(FuncTypeConverter::FunType::GHOST_IMAGE);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
m_stackedWidget = new SystemBackup(ui->centralwidget);
|
m_stackedWidget = new SystemBackup(ui->centralwidget);
|
||||||
GlobelBackupInfo::inst().setFuncType(FuncTypeConverter::FunType::BACKUP_SYSTEM);
|
GlobelBackupInfo::inst().setFuncType(FuncTypeConverter::FunType::BACKUP_SYSTEM);
|
||||||
|
|
|
@ -262,6 +262,7 @@ void DataBackup::initSecondWidget()
|
||||||
// 添加本地默认路径、移动设备目录
|
// 添加本地默认路径、移动设备目录
|
||||||
connect(m_udector, &UdiskDetector::udiskListChanged, this, [=](QList<QStorageInfo> diskList) {
|
connect(m_udector, &UdiskDetector::udiskListChanged, this, [=](QList<QStorageInfo> diskList) {
|
||||||
comboSelect->clear();
|
comboSelect->clear();
|
||||||
|
this->m_udiskPaths.clear();
|
||||||
QIcon iconFolder = QIcon::fromTheme("insync-folder.png", QIcon(":/images/folder.png"));
|
QIcon iconFolder = QIcon::fromTheme("insync-folder.png", QIcon(":/images/folder.png"));
|
||||||
|
|
||||||
// 如果有备份分区,则将本地默认分区备份路径放在第一个
|
// 如果有备份分区,则将本地默认分区备份路径放在第一个
|
||||||
|
@ -916,6 +917,7 @@ void DataBackup::on_checkEnv_start()
|
||||||
backupWrapper.m_backupPaths << m_backupPaths;
|
backupWrapper.m_backupPaths << m_backupPaths;
|
||||||
backupWrapper.m_prefixDestPath = m_prefixDestPath;
|
backupWrapper.m_prefixDestPath = m_prefixDestPath;
|
||||||
backupWrapper.m_frontUid = getuid();
|
backupWrapper.m_frontUid = getuid();
|
||||||
|
backupWrapper.m_frontUserName = qgetenv("USER");
|
||||||
backupWrapper.m_gid = getgid();
|
backupWrapper.m_gid = getgid();
|
||||||
m_pInterface->checkEnv(backupWrapper);
|
m_pInterface->checkEnv(backupWrapper);
|
||||||
}
|
}
|
||||||
|
@ -1323,6 +1325,7 @@ void DataBackup::on_backup_start()
|
||||||
backupWrapper.m_backupPaths << m_backupPaths;
|
backupWrapper.m_backupPaths << m_backupPaths;
|
||||||
backupWrapper.m_prefixDestPath = m_prefixDestPath;
|
backupWrapper.m_prefixDestPath = m_prefixDestPath;
|
||||||
backupWrapper.m_frontUid = getuid();
|
backupWrapper.m_frontUid = getuid();
|
||||||
|
backupWrapper.m_frontUserName = qgetenv("USER");
|
||||||
backupWrapper.m_gid = getgid();
|
backupWrapper.m_gid = getgid();
|
||||||
m_pInterface->goBackup(backupWrapper);
|
m_pInterface->goBackup(backupWrapper);
|
||||||
}
|
}
|
||||||
|
@ -1526,7 +1529,7 @@ void DataBackup::initLastWidget()
|
||||||
hlayoutCenterFont5->addWidget(retry);
|
hlayoutCenterFont5->addWidget(retry);
|
||||||
hlayoutCenterFont5->addSpacing(20);
|
hlayoutCenterFont5->addSpacing(20);
|
||||||
// 返回首页
|
// 返回首页
|
||||||
MyPushButton *homePage = new MyPushButton(last);
|
MyPushButton *homePage = new MyPushButton(centerFont);
|
||||||
homePage->setFixedSize(97, 36);
|
homePage->setFixedSize(97, 36);
|
||||||
homePage->setText(tr("home page"));
|
homePage->setText(tr("home page"));
|
||||||
homePage->setEnabled(true);
|
homePage->setEnabled(true);
|
||||||
|
|
|
@ -398,8 +398,8 @@ void DataRestore::initSecondWidget()
|
||||||
resultLogo->setVisible(true);
|
resultLogo->setVisible(true);
|
||||||
// 检测成功
|
// 检测成功
|
||||||
bigTitle->setDeplayText(tr("Succeeded to check the environment"));
|
bigTitle->setDeplayText(tr("Succeeded to check the environment"));
|
||||||
// 还原完成后将自动重启
|
// 不要使用电脑,以防数据丢失
|
||||||
labelCheck1->setDeplayText(tr("The system will reboot automatically after the restore is successful"));
|
labelCheck1->setDeplayText(tr("Do not use computers in case of data loss"));
|
||||||
dot2->setBackgroundColor(COLOR_YELLOW);
|
dot2->setBackgroundColor(COLOR_YELLOW);
|
||||||
labelCheck2->setFontColor(COLOR_YELLOW);
|
labelCheck2->setFontColor(COLOR_YELLOW);
|
||||||
labelCheck2->setFontWordWrap(true);
|
labelCheck2->setFontWordWrap(true);
|
||||||
|
@ -472,6 +472,7 @@ void DataRestore::on_checkEnv_start()
|
||||||
backupWrapper.m_uuid = m_uuid;
|
backupWrapper.m_uuid = m_uuid;
|
||||||
backupWrapper.m_prefixDestPath = m_devPath;
|
backupWrapper.m_prefixDestPath = m_devPath;
|
||||||
backupWrapper.m_frontUid = getuid();
|
backupWrapper.m_frontUid = getuid();
|
||||||
|
backupWrapper.m_frontUserName = qgetenv("USER");
|
||||||
backupWrapper.m_gid = getgid();
|
backupWrapper.m_gid = getgid();
|
||||||
m_pInterface->checkEnv(backupWrapper);
|
m_pInterface->checkEnv(backupWrapper);
|
||||||
}
|
}
|
||||||
|
@ -516,12 +517,6 @@ void DataRestore::on_checkEnv_end(int result)
|
||||||
// 备份点可能被损坏
|
// 备份点可能被损坏
|
||||||
errTip = tr("Backup points may be corrupted");
|
errTip = tr("Backup points may be corrupted");
|
||||||
break;
|
break;
|
||||||
case int(BackupResult::EFI_RSYNC_FAIL):
|
|
||||||
// 同步/boot/efi失败
|
|
||||||
errMsg = tr("Failed to rsync /boot/efi");
|
|
||||||
// 请检查/boot/efi分区挂载方式
|
|
||||||
errTip = tr("Check the mounting mode of the /boot/efi partition");
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
bRst = true;
|
bRst = true;
|
||||||
break;
|
break;
|
||||||
|
@ -671,6 +666,7 @@ void DataRestore::on_restore_start()
|
||||||
backupWrapper.m_uuid = m_uuid;
|
backupWrapper.m_uuid = m_uuid;
|
||||||
backupWrapper.m_prefixDestPath = m_devPath;
|
backupWrapper.m_prefixDestPath = m_devPath;
|
||||||
backupWrapper.m_frontUid = getuid();
|
backupWrapper.m_frontUid = getuid();
|
||||||
|
backupWrapper.m_frontUserName = qgetenv("USER");
|
||||||
backupWrapper.m_gid = getgid();
|
backupWrapper.m_gid = getgid();
|
||||||
m_pInterface->goRestore(backupWrapper);
|
m_pInterface->goRestore(backupWrapper);
|
||||||
}
|
}
|
||||||
|
@ -871,7 +867,7 @@ void DataRestore::initLastWidget()
|
||||||
// hlayoutCenterFont5->addSpacing(100);
|
// hlayoutCenterFont5->addSpacing(100);
|
||||||
hlayoutCenterFont5->addStretch();
|
hlayoutCenterFont5->addStretch();
|
||||||
// 返回首页
|
// 返回首页
|
||||||
MyPushButton *homePage = new MyPushButton(last);
|
MyPushButton *homePage = new MyPushButton(centerFont);
|
||||||
homePage->setFixedSize(97, 36);
|
homePage->setFixedSize(97, 36);
|
||||||
homePage->setText(tr("home page"));
|
homePage->setText(tr("home page"));
|
||||||
homePage->setEnabled(true);
|
homePage->setEnabled(true);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,77 @@
|
||||||
|
#ifndef GHOSTIMAGE_H
|
||||||
|
#define GHOSTIMAGE_H
|
||||||
|
|
||||||
|
#include <QStackedWidget>
|
||||||
|
#include "udiskdetector.h"
|
||||||
|
#include "../backup_manager_interface.h"
|
||||||
|
#include "../backup-daemon/parsebackuplist.h"
|
||||||
|
#include "../component/backuplistwidget.h"
|
||||||
|
|
||||||
|
class GhostImage : public QStackedWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
enum GhostImageState
|
||||||
|
{
|
||||||
|
IDEL = 0, // 空闲
|
||||||
|
CHECKING, // 环境校验中
|
||||||
|
GHOSTING // 备份中
|
||||||
|
};
|
||||||
|
|
||||||
|
enum GhostImagePage
|
||||||
|
{
|
||||||
|
HOME_PAGE, // 首页
|
||||||
|
SELECT_PATH_PAGE, // 选择镜像保存路径页
|
||||||
|
CHECK_ENV_PAGE, // 环境检测页
|
||||||
|
GHOSTING_PAGE, // 备份中页
|
||||||
|
LAST_PAGE, // 结束页
|
||||||
|
};
|
||||||
|
public:
|
||||||
|
explicit GhostImage(QWidget *parent = nullptr);
|
||||||
|
virtual ~GhostImage();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initFirstWidget();
|
||||||
|
void initSecondWidget();
|
||||||
|
void initThirdWidget();
|
||||||
|
void initForthWidget();
|
||||||
|
void initLastWidget();
|
||||||
|
QString createGhostImageName(const QString& backupName);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void startCheckEnv();
|
||||||
|
void checkEnvResult(bool result, const QString &errMsg = "", const QString &errTip = "");
|
||||||
|
void startGhost();
|
||||||
|
void progress(int state, int rate);
|
||||||
|
void checkGhostResult(bool result, const QString &errMsg = "", const QString &errTip = "");
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void on_pre_clicked(bool checked = false);
|
||||||
|
void on_next_clicked(bool checked = false);
|
||||||
|
void on_checkEnv_start();
|
||||||
|
void on_checkEnv_end(int result);
|
||||||
|
void on_ghost_start();
|
||||||
|
void on_checkGhost_end(int result);
|
||||||
|
void on_ghost_end(bool result);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// U盘探测
|
||||||
|
UdiskDetector* m_udector;
|
||||||
|
// U盘挂载路径列表
|
||||||
|
QStringList m_udiskPaths;
|
||||||
|
// 是否本地保存镜像
|
||||||
|
bool m_isLocal;
|
||||||
|
// 镜像状态
|
||||||
|
int m_ghostImageState;
|
||||||
|
// 增量备份选择的备份点uuid
|
||||||
|
QString m_uuid;
|
||||||
|
// 选中的备份目标路径前缀(暂指udisk挂载路径)
|
||||||
|
QString m_prefixDestPath;
|
||||||
|
// dbus接口
|
||||||
|
ComKylinBackupManagerInterface *m_pInterface;
|
||||||
|
// 备份点名称
|
||||||
|
QString m_backupName;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GHOSTIMAGE_H
|
|
@ -124,7 +124,7 @@ void ManageBackupPointList::insertLines(const QList<ParseBackupList::BackupPoint
|
||||||
QString udiskName = storage.displayName();
|
QString udiskName = storage.displayName();
|
||||||
prefixPath_to_device = QObject::tr("Udisk Device:") + " " + udiskName;
|
prefixPath_to_device = QObject::tr("Udisk Device:") + " " + udiskName;
|
||||||
} else {
|
} else {
|
||||||
prefixPath_to_device = QObject::tr("Local Disk");
|
prefixPath_to_device = QObject::tr("Local Disk:") + " " + BACKUP_SNAPSHOTS_PATH;
|
||||||
}
|
}
|
||||||
setItem(indexOfRow, Column_Index::Backup_Device, prefixPath_to_device);
|
setItem(indexOfRow, Column_Index::Backup_Device, prefixPath_to_device);
|
||||||
if (backupPoint.m_state == BACKUP_PARSE_STATE_SUCCESS_STRTING) {
|
if (backupPoint.m_state == BACKUP_PARSE_STATE_SUCCESS_STRTING) {
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
#include "../../common/utils.h"
|
#include "../../common/utils.h"
|
||||||
#include "messageboxutils.h"
|
#include "messageboxutils.h"
|
||||||
|
|
||||||
SelectRestorePoint::SelectRestorePoint(QWidget *parent, BackupPointType backupType) :
|
SelectRestorePoint::SelectRestorePoint(QWidget *parent, BackupPointType backupType, bool isOnlyShowLocal) :
|
||||||
BackupPointListDialog(parent),
|
BackupPointListDialog(parent, isOnlyShowLocal),
|
||||||
m_backupType(backupType)
|
m_backupType(backupType)
|
||||||
{
|
{
|
||||||
if (BackupPointType::SYSTEM == backupType) {
|
if (BackupPointType::SYSTEM == backupType) {
|
||||||
|
@ -41,7 +41,7 @@ SelectRestorePoint::SelectRestorePoint(QWidget *parent, BackupPointType backupTy
|
||||||
QList<QTableWidgetItem *> selectList = this->m_tableWidget->selectedItems();
|
QList<QTableWidgetItem *> selectList = this->m_tableWidget->selectedItems();
|
||||||
if (selectList.isEmpty()) {
|
if (selectList.isEmpty()) {
|
||||||
MessageBoxUtils::QMESSAGE_BOX_WARNING(this, QObject::tr("Warning"), QObject::tr("Please select one backup to continue."), QObject::tr("Ok"));
|
MessageBoxUtils::QMESSAGE_BOX_WARNING(this, QObject::tr("Warning"), QObject::tr("Please select one backup to continue."), QObject::tr("Ok"));
|
||||||
this->reject();
|
// this->reject();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ void SelectRestorePoint::insertLines(const QList<ParseBackupList::BackupPoint> &
|
||||||
else
|
else
|
||||||
prefixPath_to_device = QObject::tr("Udisk Device:") + " " + udiskName;
|
prefixPath_to_device = QObject::tr("Udisk Device:") + " " + udiskName;
|
||||||
} else {
|
} else {
|
||||||
prefixPath_to_device = QObject::tr("Local Disk");
|
prefixPath_to_device = QObject::tr("Local Disk:") + " " + BACKUP_SNAPSHOTS_PATH;
|
||||||
}
|
}
|
||||||
setItem(indexOfRow, Column_Index::Backup_Device, prefixPath_to_device);
|
setItem(indexOfRow, Column_Index::Backup_Device, prefixPath_to_device);
|
||||||
setItem(indexOfRow, Column_Index::Backup_State, backupPoint.m_state);
|
setItem(indexOfRow, Column_Index::Backup_State, backupPoint.m_state);
|
||||||
|
|
|
@ -12,7 +12,7 @@ public:
|
||||||
SYSTEM
|
SYSTEM
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit SelectRestorePoint(QWidget *parent = nullptr, BackupPointType backupType = BackupPointType::SYSTEM);
|
explicit SelectRestorePoint(QWidget *parent = nullptr, BackupPointType backupType = BackupPointType::SYSTEM, bool isOnlyShowLocal = false);
|
||||||
virtual ~SelectRestorePoint();
|
virtual ~SelectRestorePoint();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
@ -202,6 +202,7 @@ void SystemBackup::initSecondWidget()
|
||||||
// 添加本地默认路径、移动设备目录
|
// 添加本地默认路径、移动设备目录
|
||||||
connect(m_udector, &UdiskDetector::udiskListChanged, this, [=](QList<QStorageInfo> diskList) {
|
connect(m_udector, &UdiskDetector::udiskListChanged, this, [=](QList<QStorageInfo> diskList) {
|
||||||
comboSelect->clear();
|
comboSelect->clear();
|
||||||
|
this->m_udiskPaths.clear();
|
||||||
QIcon iconFolder = QIcon::fromTheme("insync-folder.png", QIcon(":/images/folder.png"));
|
QIcon iconFolder = QIcon::fromTheme("insync-folder.png", QIcon(":/images/folder.png"));
|
||||||
|
|
||||||
// 如果有备份分区,则将本地默认分区备份路径放在第一个
|
// 如果有备份分区,则将本地默认分区备份路径放在第一个
|
||||||
|
@ -505,6 +506,7 @@ void SystemBackup::on_checkEnv_start()
|
||||||
backupWrapper.m_prefixDestPath = m_prefixDestPath;
|
backupWrapper.m_prefixDestPath = m_prefixDestPath;
|
||||||
backupWrapper.m_backupExcludePaths.append(Utils::getFromExcludePathsFile());
|
backupWrapper.m_backupExcludePaths.append(Utils::getFromExcludePathsFile());
|
||||||
backupWrapper.m_frontUid = getuid();
|
backupWrapper.m_frontUid = getuid();
|
||||||
|
backupWrapper.m_frontUserName = qgetenv("USER");
|
||||||
backupWrapper.m_gid = getgid();
|
backupWrapper.m_gid = getgid();
|
||||||
m_pInterface->checkEnv(backupWrapper);
|
m_pInterface->checkEnv(backupWrapper);
|
||||||
}
|
}
|
||||||
|
@ -929,6 +931,7 @@ void SystemBackup::on_backup_start()
|
||||||
backupWrapper.m_prefixDestPath = m_prefixDestPath;
|
backupWrapper.m_prefixDestPath = m_prefixDestPath;
|
||||||
backupWrapper.m_backupExcludePaths.append(Utils::getFromExcludePathsFile());
|
backupWrapper.m_backupExcludePaths.append(Utils::getFromExcludePathsFile());
|
||||||
backupWrapper.m_frontUid = getuid();
|
backupWrapper.m_frontUid = getuid();
|
||||||
|
backupWrapper.m_frontUserName = qgetenv("USER");
|
||||||
backupWrapper.m_gid = getgid();
|
backupWrapper.m_gid = getgid();
|
||||||
m_pInterface->goBackup(backupWrapper);
|
m_pInterface->goBackup(backupWrapper);
|
||||||
}
|
}
|
||||||
|
@ -1142,7 +1145,7 @@ void SystemBackup::initLastWidget()
|
||||||
hlayoutCenterFont5->addWidget(retry);
|
hlayoutCenterFont5->addWidget(retry);
|
||||||
hlayoutCenterFont5->addSpacing(20);
|
hlayoutCenterFont5->addSpacing(20);
|
||||||
// 返回首页
|
// 返回首页
|
||||||
MyPushButton *homePage = new MyPushButton(last);
|
MyPushButton *homePage = new MyPushButton(centerFont);
|
||||||
homePage->setFixedSize(97, 36);
|
homePage->setFixedSize(97, 36);
|
||||||
homePage->setText(tr("home page"));
|
homePage->setText(tr("home page"));
|
||||||
homePage->setEnabled(true);
|
homePage->setEnabled(true);
|
||||||
|
|
|
@ -490,6 +490,7 @@ void SystemRestore::on_checkEnv_start()
|
||||||
backupWrapper.m_prefixDestPath = m_devPath;
|
backupWrapper.m_prefixDestPath = m_devPath;
|
||||||
backupWrapper.m_isOtherMachine = m_isOtherMachine ? 1 : 0;
|
backupWrapper.m_isOtherMachine = m_isOtherMachine ? 1 : 0;
|
||||||
backupWrapper.m_frontUid = getuid();
|
backupWrapper.m_frontUid = getuid();
|
||||||
|
backupWrapper.m_frontUserName = qgetenv("USER");
|
||||||
backupWrapper.m_gid = getgid();
|
backupWrapper.m_gid = getgid();
|
||||||
m_pInterface->checkEnv(backupWrapper);
|
m_pInterface->checkEnv(backupWrapper);
|
||||||
}
|
}
|
||||||
|
@ -691,6 +692,7 @@ void SystemRestore::on_restore_start()
|
||||||
backupWrapper.m_prefixDestPath = m_devPath;
|
backupWrapper.m_prefixDestPath = m_devPath;
|
||||||
backupWrapper.m_isOtherMachine = m_isOtherMachine ? 1 : 0;
|
backupWrapper.m_isOtherMachine = m_isOtherMachine ? 1 : 0;
|
||||||
backupWrapper.m_frontUid = getuid();
|
backupWrapper.m_frontUid = getuid();
|
||||||
|
backupWrapper.m_frontUserName = qgetenv("USER");
|
||||||
backupWrapper.m_gid = getgid();
|
backupWrapper.m_gid = getgid();
|
||||||
m_pInterface->goRestore(backupWrapper);
|
m_pInterface->goRestore(backupWrapper);
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 319 B |
Loading…
Reference in New Issue