出厂还原优化
This commit is contained in:
parent
1003397079
commit
4da3262b84
|
@ -544,6 +544,7 @@ generateExcludeFile() {
|
||||||
echo "/cdrom" >>$EXCLUDEFILE
|
echo "/cdrom" >>$EXCLUDEFILE
|
||||||
echo "/swap_file" >>$EXCLUDEFILE
|
echo "/swap_file" >>$EXCLUDEFILE
|
||||||
echo "/var/lib/docker/overlay2" >>$EXCLUDEFILE
|
echo "/var/lib/docker/overlay2" >>$EXCLUDEFILE
|
||||||
|
echo "/var/log" >>$EXCLUDEFILE
|
||||||
|
|
||||||
#bind挂载的目录不进行备份或还原
|
#bind挂载的目录不进行备份或还原
|
||||||
cat ${rootpath}/etc/fstab | awk '{if($4~/bind/) print $1}' |
|
cat ${rootpath}/etc/fstab | awk '{if($4~/bind/) print $1}' |
|
||||||
|
|
|
@ -1193,8 +1193,8 @@ elif [ $backupORrestore = "--restoreretainuserdata" ]; then
|
||||||
restoreAuto
|
restoreAuto
|
||||||
elif [ $backupORrestore = "--factoryrestore" ]; then
|
elif [ $backupORrestore = "--factoryrestore" ]; then
|
||||||
m_isFactory=true
|
m_isFactory=true
|
||||||
mount >>$PLOGFILE
|
|
||||||
mountBackup
|
mountBackup
|
||||||
|
mount >>$PLOGFILE
|
||||||
restoreAuto #还原, grub时只有一键还原,没有增量还原
|
restoreAuto #还原, grub时只有一键还原,没有增量还原
|
||||||
#umountBackup
|
#umountBackup
|
||||||
|
|
||||||
|
|
|
@ -360,11 +360,6 @@ void SystemRestoreProxy::restoreSystem()
|
||||||
fileIfSync.replace("//", "/");
|
fileIfSync.replace("//", "/");
|
||||||
QFileInfo file(fileIfSync);
|
QFileInfo file(fileIfSync);
|
||||||
QDateTime beginTime = file.fileTime(QFileDevice::FileModificationTime);
|
QDateTime beginTime = file.fileTime(QFileDevice::FileModificationTime);
|
||||||
if (FACTORY_BACKUP_UUID == m_curUuid && m_backupWrapper.m_type == BackupType::RESTORE_SYSTEM) {
|
|
||||||
// 出厂还原有的机器上删除/home/xxx有残留,故在此再强制删除一下,sudo rm -rf命令一遍还删除不了(报错:无法删除/home/xx/.config:目录非空,应该是删除后又自动生成了),多删除几次还不是非常干净,^_^
|
|
||||||
removeHome(Utils::getSysRootPath() + "/home");
|
|
||||||
removeHome(Utils::getSysRootPath() + "/data/home");
|
|
||||||
}
|
|
||||||
QProcess::execute("sync");
|
QProcess::execute("sync");
|
||||||
Utils::wait(20);
|
Utils::wait(20);
|
||||||
Utils::updateSyncFile();
|
Utils::updateSyncFile();
|
||||||
|
@ -375,6 +370,13 @@ void SystemRestoreProxy::restoreSystem()
|
||||||
if (UpdateTime > beginTime)
|
if (UpdateTime > beginTime)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (FACTORY_BACKUP_UUID == m_curUuid && m_backupWrapper.m_type == BackupType::RESTORE_SYSTEM) {
|
||||||
|
// 出厂还原有的机器上删除/home/xxx有残留,故在此再强制删除一下,sudo rm -rf命令一遍还删除不了(报错:无法删除/home/xx/.config:目录非空,应该是删除后又自动生成了),多删除几次还不是非常干净,^_^
|
||||||
|
removeHome(QString(Utils::getSysRootPath() + "/home").replace("//", "/"));
|
||||||
|
removeHome(QString(Utils::getSysRootPath() + "/data/home").replace("//", "/"));
|
||||||
|
}
|
||||||
|
QProcess::execute("sync");
|
||||||
|
Utils::wait(5);
|
||||||
|
|
||||||
emit this->workResult(result);
|
emit this->workResult(result);
|
||||||
Utils::wait(2);
|
Utils::wait(2);
|
||||||
|
@ -427,9 +429,7 @@ void SystemRestoreProxy::removeHome(const QString& path)
|
||||||
QStringList retainUsers = getBackupPointUsers();
|
QStringList retainUsers = getBackupPointUsers();
|
||||||
qDebug() << retainUsers;
|
qDebug() << retainUsers;
|
||||||
|
|
||||||
bool needRm = false;
|
|
||||||
QString subcmd("rm -rf ");
|
QString subcmd("rm -rf ");
|
||||||
QString delDirs;
|
|
||||||
QStringList list = dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs);
|
QStringList list = dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs);
|
||||||
for (const QString& item : list) {
|
for (const QString& item : list) {
|
||||||
// 出厂备份里面的/home/oem等保留
|
// 出厂备份里面的/home/oem等保留
|
||||||
|
@ -444,20 +444,41 @@ void SystemRestoreProxy::removeHome(const QString& path)
|
||||||
QDir subDir(subPath);
|
QDir subDir(subPath);
|
||||||
subDir.removeRecursively();
|
subDir.removeRecursively();
|
||||||
|
|
||||||
delDirs += "${rootmnt}";
|
qDebug() << (subcmd + subPath);
|
||||||
delDirs += path;
|
QProcess::execute(subcmd + subPath);
|
||||||
delDirs += "/";
|
|
||||||
delDirs += item;
|
|
||||||
delDirs += " ";
|
|
||||||
|
|
||||||
needRm = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needRm) {
|
// bool needRm = false;
|
||||||
QString cmd = QString("bash -c \"%1\" ").arg(subcmd + delDirs);
|
// QString subcmd("rm -rf ");
|
||||||
cmd.replace("${rootmnt}", "");
|
// QString delDirs;
|
||||||
QProcess::execute(cmd);
|
// QStringList list = dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs);
|
||||||
}
|
// for (const QString& item : list) {
|
||||||
|
// // 出厂备份里面的/home/oem等保留
|
||||||
|
// if (item == "oem")
|
||||||
|
// continue ;
|
||||||
|
// if (retainUsers.contains(item))
|
||||||
|
// continue ;
|
||||||
|
|
||||||
|
// QString subPath = path;
|
||||||
|
// subPath += "/";
|
||||||
|
// subPath += item;
|
||||||
|
// QDir subDir(subPath);
|
||||||
|
// subDir.removeRecursively();
|
||||||
|
|
||||||
|
// delDirs += "${rootmnt}";
|
||||||
|
// delDirs += path;
|
||||||
|
// delDirs += "/";
|
||||||
|
// delDirs += item;
|
||||||
|
// delDirs += " ";
|
||||||
|
|
||||||
|
// needRm = true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (needRm) {
|
||||||
|
// QString cmd = QString("bash -c \"%1\" ").arg(subcmd + delDirs);
|
||||||
|
// cmd.replace("${rootmnt}", "");
|
||||||
|
// QProcess::execute(cmd);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "SystemRestoreProxy::removeHome invoke end";
|
qDebug() << "SystemRestoreProxy::removeHome invoke end";
|
||||||
|
|
Loading…
Reference in New Issue