修改笔误+还原工具本身
This commit is contained in:
parent
7eeb898536
commit
8fc597cea2
|
@ -71,7 +71,7 @@ bool CustomizeGhostImageProxy::checkEnvEx()
|
|||
return false;
|
||||
}
|
||||
m_imgDst = m_srcPath + "/" + UDISK_MKSQUASHFS_IMG_NAME;
|
||||
if (!Utils::filsExists(m_imgDst)) {
|
||||
if (!Utils::fileExists(m_imgDst)) {
|
||||
emit checkResult(int(BackupResult::GHOST_SRC_DIRECTORY_IS_NOT_EXIST));
|
||||
return false;
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ void CustomizeGhostImageProxy::doGhostImage()
|
|||
if (resultRsync) {
|
||||
// 文件更名
|
||||
QString imgFileName = m_destPath + "/" + UDISK_MKSQUASHFS_IMG_NAME;
|
||||
if (Utils::filsExists(imgFileName)) {
|
||||
if (Utils::fileExists(imgFileName)) {
|
||||
QStringList args;
|
||||
args << imgFileName;
|
||||
args << m_kyimg;
|
||||
|
|
|
@ -48,7 +48,7 @@ bool CustomizeSystemRestoreProxy::checkEnvEx()
|
|||
// 2、检测.user.txt是否存在
|
||||
m_userFile = m_backupPoint.m_path + BACKUP_SNAPSHOTS_PATH + "/" + m_backupWrapper.m_uuid + "/" + PATHS_USER_FILE;
|
||||
m_userFile.replace("//", "/");
|
||||
if (!Utils::filsExists(m_userFile)) {
|
||||
if (!Utils::fileExists(m_userFile)) {
|
||||
qCritical(".user.txt文件不存在");
|
||||
emit checkResult(int(BackupResult::WRITE_BACKUP_PATHS_TO_USER_FAILED));
|
||||
return false;
|
||||
|
@ -57,7 +57,7 @@ bool CustomizeSystemRestoreProxy::checkEnvEx()
|
|||
// 3、检测.exclude.user.txt是否存在
|
||||
m_excludeUserFile = m_backupPoint.m_path + BACKUP_SNAPSHOTS_PATH + "/" + m_backupWrapper.m_uuid + "/" + EXCLUDE_PATHS_USER_FILE;
|
||||
m_excludeUserFile.replace("//", "/");
|
||||
if (!Utils::filsExists(m_excludeUserFile)) {
|
||||
if (!Utils::fileExists(m_excludeUserFile)) {
|
||||
qCritical(".exclude.user.txt文件不存在");
|
||||
emit checkResult(int(BackupResult::WRITE_EXCLUDE_BACKUP_PATHS_TO_USER_FAILED));
|
||||
return false;
|
||||
|
@ -72,7 +72,7 @@ bool CustomizeSystemRestoreProxy::checkEnvEx()
|
|||
return false;
|
||||
}
|
||||
m_imgFileName = m_backupPath + "/" + UDISK_MKSQUASHFS_IMG_NAME;
|
||||
if (!Utils::filsExists(m_imgFileName)) {
|
||||
if (!Utils::fileExists(m_imgFileName)) {
|
||||
qCritical("还原点{uuid}/data/dst.img文件不存在");
|
||||
emit checkResult(int(BackupResult::INC_NOT_FOUND_DIR));
|
||||
return false;
|
||||
|
@ -345,24 +345,22 @@ void CustomizeSystemRestoreProxy::restoreSystem()
|
|||
}
|
||||
|
||||
// 2209后新增了一些依赖,还原到以前的4.0.13版后缺少依赖无法运行,故此最后还得还原backup-daemon和kybackup本身
|
||||
// QString version = Utils::getBackupVersion();
|
||||
// if (version.contains("4.0.13"))
|
||||
// {
|
||||
// RsyncPathToDirProcess * process = new RsyncPathToDirProcess(this);
|
||||
// QStringList arguments;
|
||||
// arguments << "-avAHXr";
|
||||
// arguments << this->m_srcPath + "usr/bin/kybackup";
|
||||
// arguments << destPath + "usr/bin/";
|
||||
// process->start(args, true);
|
||||
// 兼容Qt库从5.12.8升级到5.15,系统还原的最后也将备份还原工具本身还原
|
||||
// QString version = Utils::getBackupVersion();
|
||||
// if (version.contains("4.0.13"))
|
||||
{
|
||||
// initrd.img已经还原为旧状态,需要将新版本的backup-auto-efi等脚本文件更新到initrd.img中,这样我们修改后的新逻辑才能生效
|
||||
QString msg;
|
||||
Utils::executeCMD("update-initramfs -u", msg);
|
||||
qDebug() << msg;
|
||||
|
||||
// arguments.clear();
|
||||
// arguments << "-avAHXr";
|
||||
// arguments << this->m_srcPath + "usr/bin/backup-daemon";
|
||||
// arguments << destPath + "usr/bin/";
|
||||
// process->start(args, true);
|
||||
// sync();
|
||||
// Utils::wait(5);
|
||||
// }
|
||||
// 写入标记:rsync_backup_self:${UUID}到文件/etc/file_if_sync中,表示需要还原backup-daemon和kybackup本身
|
||||
QString line("rsync_backup_self:");
|
||||
line += m_curUuid;
|
||||
Utils::syncWriteFile(fileIfSync, line);
|
||||
::sync();
|
||||
Utils::wait(5);
|
||||
}
|
||||
|
||||
emit this->workResult(result);
|
||||
Utils::wait(2);
|
||||
|
|
|
@ -43,7 +43,7 @@ bool DataRestoreProxy::checkEnvEx()
|
|||
// 1、检测.user.txt是否存在
|
||||
m_userFile = m_prePath + BACKUP_SNAPSHOTS_PATH + "/" + m_backupWrapper.m_uuid + "/" + PATHS_USER_FILE;
|
||||
m_userFile.replace("//", "/");
|
||||
if (!Utils::filsExists(m_userFile)) {
|
||||
if (!Utils::fileExists(m_userFile)) {
|
||||
qCritical(".user.txt文件不存在");
|
||||
emit checkResult(int(BackupResult::WRITE_BACKUP_PATHS_TO_USER_FAILED));
|
||||
return false;
|
||||
|
@ -52,7 +52,7 @@ bool DataRestoreProxy::checkEnvEx()
|
|||
// 2、检测.exclude.user.txt是否存在
|
||||
m_excludeUserFile = m_prePath + BACKUP_SNAPSHOTS_PATH + "/" + m_backupWrapper.m_uuid + "/" + EXCLUDE_PATHS_USER_FILE;
|
||||
m_excludeUserFile.replace("//", "/");
|
||||
if (!Utils::filsExists(m_excludeUserFile)) {
|
||||
if (!Utils::fileExists(m_excludeUserFile)) {
|
||||
qCritical(".exclude.user.txt文件不存在");
|
||||
emit checkResult(int(BackupResult::WRITE_EXCLUDE_BACKUP_PATHS_TO_USER_FAILED));
|
||||
return false;
|
||||
|
|
|
@ -38,7 +38,7 @@ bool SystemRestoreProxy::checkEnvEx()
|
|||
// 1、检测.user.txt是否存在
|
||||
m_userFile = Utils::getSysRootPath() + BACKUP_SNAPSHOTS_PATH + "/" + m_backupWrapper.m_uuid + "/" + PATHS_USER_FILE;
|
||||
m_userFile.replace("//", "/");
|
||||
if (!Utils::filsExists(m_userFile)) {
|
||||
if (!Utils::fileExists(m_userFile)) {
|
||||
qCritical(".user.txt文件不存在");
|
||||
emit checkResult(int(BackupResult::WRITE_BACKUP_PATHS_TO_USER_FAILED));
|
||||
return false;
|
||||
|
@ -47,7 +47,7 @@ bool SystemRestoreProxy::checkEnvEx()
|
|||
// 2、检测.exclude.user.txt是否存在
|
||||
m_excludeUserFile = Utils::getSysRootPath() + BACKUP_SNAPSHOTS_PATH + "/" + m_backupWrapper.m_uuid + "/" + EXCLUDE_PATHS_USER_FILE;
|
||||
m_excludeUserFile.replace("//", "/");
|
||||
if (!Utils::filsExists(m_excludeUserFile)) {
|
||||
if (!Utils::fileExists(m_excludeUserFile)) {
|
||||
qCritical(".exclude.user.txt文件不存在");
|
||||
emit checkResult(int(BackupResult::WRITE_EXCLUDE_BACKUP_PATHS_TO_USER_FAILED));
|
||||
return false;
|
||||
|
@ -416,23 +416,22 @@ void SystemRestoreProxy::restoreSystem()
|
|||
|
||||
QProcess::execute("sync");
|
||||
// 2209后新增了一些依赖,还原到以前的4.0.13版后缺少依赖无法运行,故此最后还得还原backup-daemon和kybackup本身
|
||||
// QString version = Utils::getBackupVersion();
|
||||
// if (version.contains("4.0.13"))
|
||||
// {
|
||||
// RsyncPathToDirProcess * process = new RsyncPathToDirProcess(this);
|
||||
// QStringList arguments;
|
||||
// arguments << "-avAHXr";
|
||||
// arguments << this->m_srcPath + "usr/bin/kybackup";
|
||||
// arguments << destPath + "usr/bin/";
|
||||
// process->start(args, true);
|
||||
// 兼容Qt库从5.12.8升级到5.15,系统还原的最后也将备份还原工具本身还原
|
||||
// QString version = Utils::getBackupVersion();
|
||||
// if (version.contains("4.0.13"))
|
||||
{
|
||||
// initrd.img已经还原为旧状态,需要将新版本的backup-auto-efi等脚本文件更新到initrd.img中,这样我们修改后的新逻辑才能生效
|
||||
QString msg;
|
||||
Utils::executeCMD("update-initramfs -u", msg);
|
||||
qDebug() << msg;
|
||||
|
||||
// arguments.clear();
|
||||
// arguments << "-avAHXr";
|
||||
// arguments << this->m_srcPath + "usr/bin/backup-daemon";
|
||||
// arguments << destPath + "usr/bin/";
|
||||
// process->start(args, true);
|
||||
// ::sync();
|
||||
// }
|
||||
// 写入标记:rsync_backup_self:${UUID}到文件/etc/file_if_sync中,表示需要还原backup-daemon和kybackup本身
|
||||
QString line("rsync_backup_self:");
|
||||
line += m_curUuid;
|
||||
Utils::syncWriteFile(fileIfSync, line);
|
||||
::sync();
|
||||
Utils::wait(5);
|
||||
}
|
||||
|
||||
Utils::wait(5);
|
||||
emit this->workResult(result);
|
||||
|
|
|
@ -39,7 +39,7 @@ bool UDiskDataRestoreProxy::checkEnvEx()
|
|||
|
||||
// 1、检测.user.txt是否存在
|
||||
m_userFile = m_backupWrapper.m_prefixDestPath + BACKUP_SNAPSHOTS_PATH + "/" + m_backupWrapper.m_uuid + "/" + PATHS_USER_FILE;
|
||||
if (!Utils::filsExists(m_userFile)) {
|
||||
if (!Utils::fileExists(m_userFile)) {
|
||||
qCritical(".user.txt文件不存在");
|
||||
emit checkResult(int(BackupResult::WRITE_BACKUP_PATHS_TO_USER_FAILED));
|
||||
return false;
|
||||
|
@ -47,7 +47,7 @@ bool UDiskDataRestoreProxy::checkEnvEx()
|
|||
|
||||
// 2、检测.exclude.user.txt是否存在
|
||||
m_excludeUserFile = m_backupWrapper.m_prefixDestPath + BACKUP_SNAPSHOTS_PATH + "/" + m_backupWrapper.m_uuid + "/" + EXCLUDE_PATHS_USER_FILE;
|
||||
if (!Utils::filsExists(m_excludeUserFile)) {
|
||||
if (!Utils::fileExists(m_excludeUserFile)) {
|
||||
qCritical(".exclude.user.txt文件不存在");
|
||||
emit checkResult(int(BackupResult::WRITE_EXCLUDE_BACKUP_PATHS_TO_USER_FAILED));
|
||||
return false;
|
||||
|
|
|
@ -40,7 +40,7 @@ bool UDiskSystemRestoreProxy::checkEnvEx()
|
|||
// 1、检测.user.txt是否存在
|
||||
m_userFile = m_backupWrapper.m_prefixDestPath + BACKUP_SNAPSHOTS_PATH + "/" + m_backupWrapper.m_uuid + "/" + PATHS_USER_FILE;
|
||||
m_userFile.replace("//", "/");
|
||||
if (!Utils::filsExists(m_userFile)) {
|
||||
if (!Utils::fileExists(m_userFile)) {
|
||||
qCritical(".user.txt文件不存在");
|
||||
emit checkResult(int(BackupResult::WRITE_BACKUP_PATHS_TO_USER_FAILED));
|
||||
return false;
|
||||
|
@ -49,7 +49,7 @@ bool UDiskSystemRestoreProxy::checkEnvEx()
|
|||
// 2、检测.exclude.user.txt是否存在
|
||||
m_excludeUserFile = m_backupWrapper.m_prefixDestPath + BACKUP_SNAPSHOTS_PATH + "/" + m_backupWrapper.m_uuid + "/" + EXCLUDE_PATHS_USER_FILE;
|
||||
m_excludeUserFile.replace("//", "/");
|
||||
if (!Utils::filsExists(m_excludeUserFile)) {
|
||||
if (!Utils::fileExists(m_excludeUserFile)) {
|
||||
qCritical(".exclude.user.txt文件不存在");
|
||||
emit checkResult(int(BackupResult::WRITE_EXCLUDE_BACKUP_PATHS_TO_USER_FAILED));
|
||||
return false;
|
||||
|
@ -374,7 +374,7 @@ bool UDiskSystemRestoreProxy::doPrepare()
|
|||
|
||||
// 移动设备系统备份如果有img,则需要先将img挂载到/backup/imgbackup目录
|
||||
QString imgPath = m_backupPath + "/" + UDISK_MKSQUASHFS_IMG_NAME;
|
||||
if (Utils::filsExists(imgPath)) {
|
||||
if (Utils::fileExists(imgPath)) {
|
||||
// 1、检测目录/backup/imgbackup是否存在,不存在则创建此目录
|
||||
QString dstImgMountPath = Utils::getSysRootPath() + BACKUP_IMGBACKUP_PATH;
|
||||
dstImgMountPath.replace("//", "/");
|
||||
|
@ -469,24 +469,22 @@ void UDiskSystemRestoreProxy::restoreSystem()
|
|||
}
|
||||
|
||||
// 2209后新增了一些依赖,还原到以前的4.0.13版后缺少依赖无法运行,故此最后还得还原backup-daemon和kybackup本身
|
||||
// QString version = Utils::getBackupVersion();
|
||||
// if (version.contains("4.0.13"))
|
||||
// {
|
||||
// RsyncPathToDirProcess * process = new RsyncPathToDirProcess(this);
|
||||
// QStringList arguments;
|
||||
// arguments << "-avAHXr";
|
||||
// arguments << this->m_srcPath + "usr/bin/kybackup";
|
||||
// arguments << destPath + "usr/bin/";
|
||||
// process->start(args, true);
|
||||
// 兼容Qt库从5.12.8升级到5.15,系统还原的最后也将备份还原工具本身还原
|
||||
// QString version = Utils::getBackupVersion();
|
||||
// if (version.contains("4.0.13"))
|
||||
{
|
||||
// initrd.img已经还原为旧状态,需要将新版本的backup-auto-efi等脚本文件更新到initrd.img中,这样我们修改后的新逻辑才能生效
|
||||
QString msg;
|
||||
Utils::executeCMD("update-initramfs -u", msg);
|
||||
qDebug() << msg;
|
||||
|
||||
// arguments.clear();
|
||||
// arguments << "-avAHXr";
|
||||
// arguments << this->m_srcPath + "usr/bin/backup-daemon";
|
||||
// arguments << destPath + "usr/bin/";
|
||||
// process->start(args, true);
|
||||
// sync();
|
||||
// Utils::wait(5);
|
||||
// }
|
||||
// 写入标记:rsync_backup_self:${UUID}到文件/etc/file_if_sync中,表示需要还原backup-daemon和kybackup本身
|
||||
QString line("rsync_backup_self:");
|
||||
line += m_curUuid;
|
||||
Utils::syncWriteFile(fileIfSync, line);
|
||||
::sync();
|
||||
Utils::wait(5);
|
||||
}
|
||||
}
|
||||
|
||||
if (Utils::isDirEmpty(m_backupPath))
|
||||
|
|
|
@ -611,7 +611,7 @@ bool Utils::writeFileByLines(const QString& fileName, const QStringList& lines)
|
|||
* @author zhaominyong
|
||||
* @since 2021/05/29
|
||||
*/
|
||||
bool Utils::filsExists(const QString &fileName)
|
||||
bool Utils::fileExists(const QString &fileName)
|
||||
{
|
||||
struct stat buffer;
|
||||
return (stat(fileName.toStdString().data(), &buffer) == 0);
|
||||
|
@ -650,7 +650,7 @@ bool Utils::writeBackupLog(QString line)
|
|||
logFile.replace("//", "/");
|
||||
std::string fileName(logFile.toStdString());
|
||||
// 判断文件是否存在
|
||||
bool exists = filsExists(logFile);
|
||||
bool exists = fileExists(logFile);
|
||||
|
||||
std::unique_ptr<std::FILE, int (*)(std::FILE*)> fp(std::fopen(fileName.data(), "a+"), std::fclose);
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ public:
|
|||
* @author zhaominyong
|
||||
* @since 2021/05/29
|
||||
*/
|
||||
static bool filsExists(const QString &fileName);
|
||||
static bool fileExists(const QString &fileName);
|
||||
|
||||
/**
|
||||
* @brief 判断目录是否为空
|
||||
|
|
Loading…
Reference in New Issue