128105 【备份还原】创建Ghost镜像到空间足够的U盘中,创建成功后在U盘目录下没有镜像文件
This commit is contained in:
parent
270be78609
commit
4673cc8243
|
@ -89,6 +89,8 @@ void CustomizeDataBackupProxy::doWorkEx()
|
|||
*/
|
||||
void CustomizeDataBackupProxy::cancelEx()
|
||||
{
|
||||
qDebug() << "CustomizeDataBackupProxy::cancelEx invoke begin";
|
||||
|
||||
m_bCancel = true;
|
||||
if (!m_isFinished) {
|
||||
emit this->checkResult(int(BackupResult::START_CANCEL));
|
||||
|
@ -103,6 +105,8 @@ void CustomizeDataBackupProxy::cancelEx()
|
|||
deleteFailedData();
|
||||
emit this->checkResult(int(BackupResult::CANCEL_SUCCESS));
|
||||
}
|
||||
|
||||
qDebug() << "CustomizeDataBackupProxy::cancelEx invoke end";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,6 +36,8 @@ CustomizeGhostImageProxy::~CustomizeGhostImageProxy()
|
|||
*/
|
||||
bool CustomizeGhostImageProxy::checkEnvEx()
|
||||
{
|
||||
qDebug() << "CustomizeGhostImageProxy::checkEnvEx invoke begin";
|
||||
|
||||
// 1、检查/backup分区是否挂载上(不管是本地磁盘还是u盘设备,都得保证/backup挂载上); 若没挂载,挂载
|
||||
MyMountProxy mountProxy;
|
||||
MountResult result = mountProxy.mountBackupPartition();
|
||||
|
@ -94,6 +96,8 @@ bool CustomizeGhostImageProxy::checkEnvEx()
|
|||
}
|
||||
|
||||
emit checkResult(int(BackupResult::CHECK_ENV_SUCCESS));
|
||||
|
||||
qDebug() << "CustomizeGhostImageProxy::checkEnvEx invoke end";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -102,10 +106,14 @@ bool CustomizeGhostImageProxy::checkEnvEx()
|
|||
*/
|
||||
void CustomizeGhostImageProxy::doWorkEx()
|
||||
{
|
||||
qDebug() << "CustomizeGhostImageProxy::doWorkEx invoke begin";
|
||||
|
||||
if (!checkEnvEx())
|
||||
return ;
|
||||
|
||||
doGhostImage();
|
||||
|
||||
qDebug() << "CustomizeGhostImageProxy::doWorkEx invoke end";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,6 +121,8 @@ void CustomizeGhostImageProxy::doWorkEx()
|
|||
*/
|
||||
void CustomizeGhostImageProxy::cancelEx()
|
||||
{
|
||||
qDebug() << "CustomizeGhostImageProxy::cancelEx invoke begin";
|
||||
|
||||
m_bCancel = true;
|
||||
if (!m_isFinished) {
|
||||
emit this->checkResult(int(BackupResult::START_CANCEL));
|
||||
|
@ -125,6 +135,8 @@ void CustomizeGhostImageProxy::cancelEx()
|
|||
deleteFailedData();
|
||||
emit this->checkResult(int(BackupResult::CANCEL_SUCCESS));
|
||||
}
|
||||
|
||||
qDebug() << "CustomizeGhostImageProxy::cancelEx invoke end";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,6 +162,8 @@ void CustomizeGhostImageProxy::deleteFailedData()
|
|||
*/
|
||||
void CustomizeGhostImageProxy::doGhostImage()
|
||||
{
|
||||
qDebug() << "CustomizeGhostImageProxy::doGhostImage invoke begin";
|
||||
|
||||
// 同步到U盘
|
||||
m_p = new RsyncPathToDirProcess(this);
|
||||
connect(m_p, &RsyncPathToDirProcess::progress, this, &CustomizeGhostImageProxy::progress);
|
||||
|
@ -188,6 +202,8 @@ void CustomizeGhostImageProxy::doGhostImage()
|
|||
|
||||
QTimer::singleShot(1*1000, this, &CustomizeGhostImageProxy::checkDestDirExists);
|
||||
m_p->start(arguments, false);
|
||||
|
||||
qDebug() << "CustomizeGhostImageProxy::doGhostImage invoke end";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -262,6 +262,8 @@ QStringList CustomizeSystemRestoreProxy::getRsyncArgs(CustomizeSystemRestoreScen
|
|||
*/
|
||||
void CustomizeSystemRestoreProxy::restoreSystem()
|
||||
{
|
||||
qDebug() << "CustomizeSystemRestoreProxy::restoreSystem invoke begin";
|
||||
|
||||
// 还原前准备
|
||||
doPrepare();
|
||||
|
||||
|
@ -311,5 +313,7 @@ void CustomizeSystemRestoreProxy::restoreSystem()
|
|||
});
|
||||
|
||||
m_p->start(args, false);
|
||||
|
||||
qDebug() << "CustomizeSystemRestoreProxy::restoreSystem invoke end";
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ DeleteBackupProxy::~DeleteBackupProxy()
|
|||
|
||||
void DeleteBackupProxy::doWorkEx()
|
||||
{
|
||||
qDebug() << "DeleteBackupProxy::doWorkEx invoke begin";
|
||||
|
||||
// 1、删除/backup/snapshots/backuplist.xml对应项
|
||||
if (!deleteXmlBackupPoint())
|
||||
return;
|
||||
|
@ -26,6 +28,8 @@ void DeleteBackupProxy::doWorkEx()
|
|||
|
||||
// 删除成功信号
|
||||
emit workResult(true);
|
||||
|
||||
qDebug() << "DeleteBackupProxy::doWorkEx invoke end";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,6 +37,8 @@ void DeleteBackupProxy::doWorkEx()
|
|||
*/
|
||||
bool DeleteBackupProxy::deleteXmlBackupPoint()
|
||||
{
|
||||
qDebug() << "DeleteBackupProxy::deleteXmlBackupPoint invoke begin";
|
||||
|
||||
QString xmlPath;
|
||||
if (m_backupWrapper.m_iPosition == BackupPosition::LOCAL || m_backupWrapper.m_iPosition == BackupPosition::CUSTOMIZE)
|
||||
xmlPath = Utils::getSysRootPath() + BACKUP_XML_PATH;
|
||||
|
@ -51,6 +57,7 @@ bool DeleteBackupProxy::deleteXmlBackupPoint()
|
|||
return false;
|
||||
}
|
||||
|
||||
qDebug() << "DeleteBackupProxy::deleteXmlBackupPoint invoke end";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -59,6 +66,8 @@ bool DeleteBackupProxy::deleteXmlBackupPoint()
|
|||
*/
|
||||
void DeleteBackupProxy::deleteBackupPointDir()
|
||||
{
|
||||
qDebug() << "DeleteBackupProxy::deleteBackupPointDir invoke begin";
|
||||
|
||||
QString uuidPath;
|
||||
if (m_backupPoint.m_iPosition == BackupPosition::LOCAL)
|
||||
uuidPath = Utils::getSysRootPath() + BACKUP_SNAPSHOTS_PATH + "/" + m_backupWrapper.m_uuid;
|
||||
|
@ -81,5 +90,7 @@ void DeleteBackupProxy::deleteBackupPointDir()
|
|||
} else {
|
||||
Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,,," + m_backupPoint.m_backupName);
|
||||
}
|
||||
|
||||
qDebug() << "DeleteBackupProxy::deleteBackupPointDir invoke end";
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@ GhostImageProxy::~GhostImageProxy()
|
|||
*/
|
||||
bool GhostImageProxy::checkEnvEx()
|
||||
{
|
||||
qDebug() << "GhostImageProxy::checkEnvEx invoke begin";
|
||||
|
||||
// 1、检查/backup分区是否挂载上(不管是本地磁盘还是u盘设备,都得保证/backup挂载上); 若没挂载,挂载
|
||||
MyMountProxy mountProxy;
|
||||
if ( MountResult::MOUNTED != mountProxy.mountBackupPartition() ) {
|
||||
|
@ -76,6 +78,8 @@ bool GhostImageProxy::checkEnvEx()
|
|||
}
|
||||
|
||||
emit checkResult(int(BackupResult::CHECK_ENV_SUCCESS));
|
||||
|
||||
qDebug() << "GhostImageProxy::checkEnvEx invoke end";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -84,10 +88,14 @@ bool GhostImageProxy::checkEnvEx()
|
|||
*/
|
||||
void GhostImageProxy::doWorkEx()
|
||||
{
|
||||
qDebug() << "GhostImageProxy::doWorkEx invoke begin";
|
||||
|
||||
if (!checkEnvEx())
|
||||
return ;
|
||||
|
||||
doGhostImage();
|
||||
|
||||
qDebug() << "GhostImageProxy::doWorkEx invoke end";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,6 +103,8 @@ void GhostImageProxy::doWorkEx()
|
|||
*/
|
||||
void GhostImageProxy::cancelEx()
|
||||
{
|
||||
qDebug() << "GhostImageProxy::cancelEx invoke begin";
|
||||
|
||||
m_bCancel = true;
|
||||
if (!m_isFinished) {
|
||||
emit this->checkResult(int(BackupResult::START_CANCEL));
|
||||
|
@ -107,6 +117,8 @@ void GhostImageProxy::cancelEx()
|
|||
deleteFailedData();
|
||||
emit this->checkResult(int(BackupResult::CANCEL_SUCCESS));
|
||||
}
|
||||
|
||||
qDebug() << "GhostImageProxy::cancelEx invoke end";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -127,6 +139,8 @@ void GhostImageProxy::deleteFailedData()
|
|||
*/
|
||||
void GhostImageProxy::doGhostImage()
|
||||
{
|
||||
qDebug() << "GhostImageProxy::doGhostImage invoke begin";
|
||||
|
||||
QStringList args;
|
||||
// 拼接备份源路径和目标路径
|
||||
QString srcPath = Utils::getSysRootPath() + BACKUP_SNAPSHOTS_PATH + "/" + m_backupWrapper.m_uuid + "/data";
|
||||
|
@ -137,6 +151,8 @@ void GhostImageProxy::doGhostImage()
|
|||
m_mksquashfs = new MkSquashFSProcess(this);
|
||||
connect(m_mksquashfs, &MkSquashFSProcess::progress, this, &GhostImageProxy::progress);
|
||||
connect(m_mksquashfs, &MkSquashFSProcess::finished, this, [&](bool result) {
|
||||
qDebug() << "GhostImageProxy::finished invoke begin";
|
||||
|
||||
// 如果是取消了操作,则不再发送其它信息
|
||||
if (m_bCancel)
|
||||
return ;
|
||||
|
@ -154,8 +170,12 @@ void GhostImageProxy::doGhostImage()
|
|||
m_bSuccess = true;
|
||||
}
|
||||
emit this->workResult(result);
|
||||
|
||||
qDebug() << "GhostImageProxy::finished invoke end";
|
||||
});
|
||||
m_bSuccess = false;
|
||||
m_mksquashfs->start(args);
|
||||
|
||||
qDebug() << "GhostImageProxy::doGhostImage invoke end";
|
||||
}
|
||||
|
||||
|
|
|
@ -126,6 +126,8 @@ QStringList UDiskDataRestoreProxy::getRsyncArgs(DataRestoreScene scene)
|
|||
*/
|
||||
void UDiskDataRestoreProxy::restoreData()
|
||||
{
|
||||
qDebug() << "UDiskDataRestoreProxy::restoreData invoke begin";
|
||||
|
||||
QStringList args = getRsyncArgs(DataRestoreScene::DATA_RESTORE);
|
||||
|
||||
m_srcPath = m_backupPath;
|
||||
|
@ -151,6 +153,8 @@ void UDiskDataRestoreProxy::restoreData()
|
|||
m_isFinished = false;
|
||||
m_bSuccess = false;
|
||||
m_p->start(args, false);
|
||||
|
||||
qDebug() << "UDiskDataRestoreProxy::restoreData invoke end";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,6 +38,8 @@ UDiskGhostImageProxy::~UDiskGhostImageProxy()
|
|||
*/
|
||||
bool UDiskGhostImageProxy::checkEnvEx()
|
||||
{
|
||||
qDebug() << "UDiskGhostImageProxy::checkEnvEx invoke begin";
|
||||
|
||||
// 1、检查/backup分区是否挂载上(不管是本地磁盘还是u盘设备,都得保证/backup挂载上); 若没挂载,挂载
|
||||
MyMountProxy mountProxy;
|
||||
if ( MountResult::MOUNTED != mountProxy.mountBackupPartition() ) {
|
||||
|
@ -103,7 +105,7 @@ bool UDiskGhostImageProxy::checkEnvEx()
|
|||
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) {
|
||||
if (leftSize > itotalSize / 2) {
|
||||
Utils::mkpath(path + GHOST_PATH);
|
||||
m_kyimg = path + GHOST_PATH + "/" + m_backupWrapper.m_backupName;
|
||||
m_kyimg.replace("//", "/");
|
||||
|
@ -121,6 +123,8 @@ bool UDiskGhostImageProxy::checkEnvEx()
|
|||
}
|
||||
|
||||
emit checkResult(int(BackupResult::CHECK_ENV_SUCCESS));
|
||||
|
||||
qDebug() << "UDiskGhostImageProxy::checkEnvEx invoke end";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -129,10 +133,14 @@ bool UDiskGhostImageProxy::checkEnvEx()
|
|||
*/
|
||||
void UDiskGhostImageProxy::doWorkEx()
|
||||
{
|
||||
qDebug() << "UDiskGhostImageProxy::doWorkEx invoke begin";
|
||||
|
||||
if (!checkEnvEx())
|
||||
return ;
|
||||
|
||||
doGhostImage();
|
||||
|
||||
qDebug() << "UDiskGhostImageProxy::doWorkEx invoke end";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -181,6 +189,8 @@ void UDiskGhostImageProxy::deleteFailedData()
|
|||
*/
|
||||
void UDiskGhostImageProxy::doGhostImage()
|
||||
{
|
||||
qDebug() << "UDiskGhostImageProxy::doGhostImage invoke begin";
|
||||
|
||||
QStringList args;
|
||||
// 拼接备份源路径和目标路径
|
||||
QString srcPath = Utils::getSysRootPath() + BACKUP_SNAPSHOTS_PATH + "/" + m_backupWrapper.m_uuid + "/data";
|
||||
|
@ -191,6 +201,8 @@ void UDiskGhostImageProxy::doGhostImage()
|
|||
m_mksquashfs = new MkSquashFSProcess(this);
|
||||
connect(m_mksquashfs, &MkSquashFSProcess::progress, this, &UDiskGhostImageProxy::progress);
|
||||
connect(m_mksquashfs, &MkSquashFSProcess::finished, this, [&](bool result) {
|
||||
qDebug() << "UDiskGhostImageProxy::finished invoke begin";
|
||||
|
||||
// 如果是取消了操作,则不再发送其它信息
|
||||
if (m_bCancel)
|
||||
return ;
|
||||
|
@ -238,12 +250,15 @@ void UDiskGhostImageProxy::doGhostImage()
|
|||
emit this->workResult(false);
|
||||
}
|
||||
|
||||
qDebug() << "UDiskGhostImageProxy::finished invoke end";
|
||||
});
|
||||
m_bSuccess = false;
|
||||
m_isFinished = false;
|
||||
m_mksquashfs->start(args);
|
||||
emit checkResult(int(BackupResult::GHOST_START_SUCCESS));
|
||||
QTimer::singleShot(1*1000, this, &UDiskGhostImageProxy::checkDestDirExists);
|
||||
|
||||
qDebug() << "UDiskGhostImageProxy::doGhostImage invoke end";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -333,6 +333,8 @@ QStringList UDiskSystemRestoreProxy::getRsyncArgs(SystemRestoreScene scene)
|
|||
*/
|
||||
bool UDiskSystemRestoreProxy::doPrepare()
|
||||
{
|
||||
qDebug() << "UDiskSystemRestoreProxy::doPrepare invoke begin";
|
||||
|
||||
// 移动设备系统备份如果有img,则需要先将img挂载到/backup/imgbackup目录
|
||||
QString imgPath = m_backupPath + "/" + UDISK_MKSQUASHFS_IMG_NAME;
|
||||
if (Utils::filsExists(imgPath)) {
|
||||
|
@ -358,6 +360,7 @@ bool UDiskSystemRestoreProxy::doPrepare()
|
|||
// 以读写方式重新挂载boot分区,因为有的机器默认以只读挂载
|
||||
remountBoot();
|
||||
|
||||
qDebug() << "UDiskSystemRestoreProxy::doPrepare invoke end";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -366,6 +369,8 @@ bool UDiskSystemRestoreProxy::doPrepare()
|
|||
*/
|
||||
void UDiskSystemRestoreProxy::restoreSystem()
|
||||
{
|
||||
qDebug() << "UDiskSystemRestoreProxy::restoreSystem invoke begin";
|
||||
|
||||
// 理论上开始不会走下面这个U盘拔出的校验
|
||||
if (m_isForce) {
|
||||
qCritical("U盘已拔出");
|
||||
|
@ -437,6 +442,8 @@ void UDiskSystemRestoreProxy::restoreSystem()
|
|||
QTimer::singleShot(1*1000, this, &UDiskSystemRestoreProxy::checkUdiskExists);
|
||||
m_isFinished = false;
|
||||
m_p->start(args, false);
|
||||
|
||||
qDebug() << "UDiskSystemRestoreProxy::restoreSystem invoke end";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -548,6 +548,11 @@ void GhostImage::on_checkEnv_start()
|
|||
backupWrapper.m_uuid = m_uuid;
|
||||
backupWrapper.m_type = BackupType::GHOST_IMAGE;
|
||||
backupWrapper.m_backupName = createGhostImageName(m_backupName);
|
||||
QString prePath = Utils::getSysRootPath() + "/media";
|
||||
prePath = prePath.replace("//", "/");
|
||||
if (m_iPosition != BackupPosition::CUSTOMIZE && m_prefixDestPath.startsWith(prePath)) {
|
||||
backupWrapper.m_iPosition = BackupPosition::UDISK;
|
||||
}
|
||||
backupWrapper.m_iPosition = m_iPosition;
|
||||
backupWrapper.m_prefixDestPath = m_prefixDestPath;
|
||||
backupWrapper.m_frontUid = getuid();
|
||||
|
|
Loading…
Reference in New Issue