diff --git a/backup-daemon/datarestoreproxy.cpp b/backup-daemon/datarestoreproxy.cpp index 90406e2..4d76aaf 100755 --- a/backup-daemon/datarestoreproxy.cpp +++ b/backup-daemon/datarestoreproxy.cpp @@ -6,6 +6,7 @@ #include #include "../common/utils.h" #include "mymountproxy.h" +#include "parsebackuplist.h" IMPLEMENT_DYNCREATE(DataRestoreProxy) @@ -61,6 +62,17 @@ bool DataRestoreProxy::checkEnvEx() return false; } + // 4、检测xml中的还原点是否还存在 + QString xmlPath = Utils::getSysRootPath() + BACKUP_XML_PATH; + xmlPath.replace("//", "/"); + ParseBackupList parse(xmlPath); + m_backupPoint = parse.findBackupPointByUuid(m_backupWrapper.m_uuid); + if (m_backupPoint.m_uuid.isEmpty()) { + qCritical("xml中还原点不存在"); + emit checkResult(int(BackupResult::INC_NOT_FOUND_DIR)); + return false; + } + emit checkResult(int(BackupResult::CHECK_ENV_SUCCESS)); qDebug() << "DataRestoreProxy::checkEnvEx invoke end"; @@ -128,7 +140,7 @@ void DataRestoreProxy::restoreData() connect(m_p, &RsyncPathToDirProcess::finished, this, [&](bool result) { if (result) { QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss"); - Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)+ "," + m_backupWrapper.m_backupName); + Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)+ "," + m_backupPoint.m_backupName); } emit this->workResult(result); }); diff --git a/backup-daemon/deletebackupproxy.cpp b/backup-daemon/deletebackupproxy.cpp index b9e4dba..dae525b 100755 --- a/backup-daemon/deletebackupproxy.cpp +++ b/backup-daemon/deletebackupproxy.cpp @@ -42,10 +42,10 @@ bool DeleteBackupProxy::deleteXmlBackupPoint() xmlPath.replace("//", "/"); ParseBackupList parse(xmlPath); // 查询节点 - ParseBackupList::BackupPoint backupPoint = parse.findBackupPointByUuid(m_backupWrapper.m_uuid); - if ( int(BackupType::BACKUP_DATA) != backupPoint.m_type - && int(BackupType::INC_BACKUP_DATA) != backupPoint.m_type) { - m_backupWrapper.m_type = backupPoint.m_type; + m_backupPoint = parse.findBackupPointByUuid(m_backupWrapper.m_uuid); + if ( int(BackupType::BACKUP_DATA) != m_backupPoint.m_type + && int(BackupType::INC_BACKUP_DATA) != m_backupPoint.m_type) { + m_backupWrapper.m_type = m_backupPoint.m_type; } // 删除节点 @@ -79,9 +79,9 @@ void DeleteBackupProxy::deleteBackupPointDir() QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss"); if ( int(BackupType::BACKUP_DATA) == m_backupWrapper.m_type || int(BackupType::INC_BACKUP_DATA) == m_backupWrapper.m_type) { - Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)+ "," + m_backupWrapper.m_backupName); + Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)+ "," + m_backupPoint.m_backupName); } else { - Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,,," + m_backupWrapper.m_backupName); + Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,,," + m_backupPoint.m_backupName); } } diff --git a/backup-daemon/systemrestoreproxy.cpp b/backup-daemon/systemrestoreproxy.cpp index 56d07fa..879922e 100755 --- a/backup-daemon/systemrestoreproxy.cpp +++ b/backup-daemon/systemrestoreproxy.cpp @@ -61,6 +61,17 @@ bool SystemRestoreProxy::checkEnvEx() return false; } + // 4、检测xml中的还原点是否还存在 + QString xmlPath = Utils::getSysRootPath() + BACKUP_XML_PATH; + xmlPath.replace("//", "/"); + ParseBackupList parse(xmlPath); + m_backupPoint = parse.findBackupPointByUuid(m_backupWrapper.m_uuid); + if (m_backupPoint.m_uuid.isEmpty()) { + qCritical("xml中还原点不存在"); + emit checkResult(int(BackupResult::INC_NOT_FOUND_DIR)); + return false; + } + m_curUuid = m_backupWrapper.m_uuid; emit checkResult(int(BackupResult::CHECK_ENV_SUCCESS)); @@ -337,7 +348,7 @@ void SystemRestoreProxy::restoreSystem() if (result) { QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss"); // Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)); - Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,,," + m_backupWrapper.m_backupName); + Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,,," + m_backupPoint.m_backupName); Utils::updateSyncFile(); QString fileIfSync = Utils::getSysRootPath() + FILE_IF_SYNC; diff --git a/backup-daemon/udiskdatarestoreproxy.cpp b/backup-daemon/udiskdatarestoreproxy.cpp index 04af6fe..df00450 100755 --- a/backup-daemon/udiskdatarestoreproxy.cpp +++ b/backup-daemon/udiskdatarestoreproxy.cpp @@ -60,6 +60,17 @@ bool UDiskDataRestoreProxy::checkEnvEx() return false; } + // 4、检测xml中的还原点是否还存在 + QString xmlPath = Utils::getSysRootPath() + BACKUP_XML_PATH; + xmlPath.replace("//", "/"); + ParseBackupList parse(xmlPath); + m_backupPoint = parse.findBackupPointByUuid(m_backupWrapper.m_uuid); + if (m_backupPoint.m_uuid.isEmpty()) { + qCritical("xml中还原点不存在"); + emit checkResult(int(BackupResult::INC_NOT_FOUND_DIR)); + return false; + } + emit checkResult(int(BackupResult::CHECK_ENV_SUCCESS)); qDebug() << "UDiskDataRestoreProxy::checkEnvEx invoke end"; @@ -129,7 +140,7 @@ void UDiskDataRestoreProxy::restoreData() m_isFinished = true; if (result) { QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss"); - Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)+ "," + m_backupWrapper.m_backupName); + Utils::writeBackupLog(time + "," + m_backupWrapper.m_uuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)+ "," + m_backupPoint.m_backupName); } emit this->workResult(result); }); diff --git a/backup-daemon/udisksystemrestoreproxy.cpp b/backup-daemon/udisksystemrestoreproxy.cpp index 57ca28f..61a5428 100755 --- a/backup-daemon/udisksystemrestoreproxy.cpp +++ b/backup-daemon/udisksystemrestoreproxy.cpp @@ -63,6 +63,17 @@ bool UDiskSystemRestoreProxy::checkEnvEx() return false; } + // 4、检测xml中的还原点是否还存在 + QString xmlPath = Utils::getSysRootPath() + BACKUP_XML_PATH; + xmlPath.replace("//", "/"); + ParseBackupList parse(xmlPath); + m_backupPoint = parse.findBackupPointByUuid(m_backupWrapper.m_uuid); + if (m_backupPoint.m_uuid.isEmpty()) { + qCritical("xml中还原点不存在"); + emit checkResult(int(BackupResult::INC_NOT_FOUND_DIR)); + return false; + } + m_curUuid = m_backupWrapper.m_uuid; emit checkResult(int(BackupResult::CHECK_ENV_SUCCESS)); @@ -346,6 +357,9 @@ bool UDiskSystemRestoreProxy::doPrepare() */ void UDiskSystemRestoreProxy::restoreSystem() { + // 停止安全防护 + QProcess::execute("systemctl stop kysec-init.service"); + QString destPath = Utils::getSysRootPath(); QStringList args; @@ -367,7 +381,7 @@ void UDiskSystemRestoreProxy::restoreSystem() if (result) { QString time = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss"); // Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,," + QString::number(m_backupWrapper.m_frontUid)); - Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,,," + m_backupWrapper.m_backupName); + Utils::writeBackupLog(time + "," + m_curUuid + "," + QString::number(m_backupWrapper.m_type) + ",,,," + m_backupPoint.m_backupName); Utils::updateSyncFile(); QString fileIfSync = Utils::getSysRootPath() + FILE_IF_SYNC; diff --git a/common/utils.cpp b/common/utils.cpp index a0318ec..d404eaf 100755 --- a/common/utils.cpp +++ b/common/utils.cpp @@ -944,11 +944,11 @@ QList Utils::getBackupLogList() if (FACTORY_BACKUP_UUID == record.m_uuid) { record.m_backupName = QObject::tr("Factory Backup"); } -// else if (AUTO_BACKUP_UUID == record.m_uuid) { -// record.m_backupName = QObject::tr("Auto Backup"); -// } + else if (AUTO_BACKUP_UUID == record.m_uuid) { + record.m_backupName = QObject::tr("Auto Backup"); + } else { - record.m_backupName = record.m_uuid; + record.m_backupName = record.m_time; } } @@ -1131,6 +1131,18 @@ void Utils::deleteBackupUniqueRecord(const QString& backupName) udisk_unique_settings.remove(backupName); } +QMap Utils::getBackupUuidNameMap() +{ + QString backupUniqueSetting = Utils::getSysRootPath() + UDISK_UNIQUE_SETTINGS; + backupUniqueSetting.replace("//", "/"); + QSettings udisk_unique_settings(backupUniqueSetting, QSettings::IniFormat); + QStringList groups = udisk_unique_settings.childGroups(); + + QMap result; + + return result; +} + /** * @brief 前后两次调用,然后取文件修改时间用于判断缓存数据是否落盘 * @return diff --git a/common/utils.h b/common/utils.h index e6bfa29..1fcfc2b 100755 --- a/common/utils.h +++ b/common/utils.h @@ -293,6 +293,12 @@ public: */ static void deleteBackupUniqueRecord(const QString& backupName); + /** + * @brief 获取备份点Uuid-BackupName键值对 + * @return Uuid-BackupName键值对 + */ + static QMap getBackupUuidNameMap(); + /** * @brief 前后两次调用,然后取文件修改时间用于判断缓存数据是否落盘 * @return