diff --git a/backup-daemon/systemrestoreproxy.cpp b/backup-daemon/systemrestoreproxy.cpp index e18b032..2d2bad3 100755 --- a/backup-daemon/systemrestoreproxy.cpp +++ b/backup-daemon/systemrestoreproxy.cpp @@ -228,6 +228,8 @@ QStringList SystemRestoreProxy::getRsyncArgs(SystemRestoreScene scene) args << "--exclude=/data/home"; args << "--exclude=/data/root"; + // 云桌面背景路径属于用户数据 + args << "--exclude=/var/lib/AccountsService"; // 此处不要break,因为还需要排除SYSTEM_RESTORE中的项 case SystemRestoreScene::SYSTEM_RESTORE : diff --git a/backup-daemon/udisksystemrestoreproxy.cpp b/backup-daemon/udisksystemrestoreproxy.cpp index b5aba0c..ab4d704 100755 --- a/backup-daemon/udisksystemrestoreproxy.cpp +++ b/backup-daemon/udisksystemrestoreproxy.cpp @@ -213,6 +213,29 @@ QStringList UDiskSystemRestoreProxy::getRsyncArgs(SystemRestoreScene scene) QStringList excludes; switch (scene) { + case SystemRestoreScene::RESTORE_SYSTEM_WITH_DATA : + args << "--exclude=/home"; + args << "--exclude=/root"; + if (Utils::isHuawei990()) { + args << "--exclude=/data"; + } else { + args << "--exclude=/data/usershare"; + } + // 保留指纹数据,用户密码、角色、权限、生物识别等信息不需要改变 + args << "--exclude=/var/lib/biometric-auth"; + args << "--exclude=/data/sec_storage_data"; + args << "--exclude=/etc/passwd"; + args << "--exclude=/etc/shadow"; + args << "--exclude=/etc/group"; + args << "--exclude=/etc/gshadow"; + args << "--exclude=/etc/sudoers"; + args << "--exclude=/data/home"; + args << "--exclude=/data/root"; + + // 云桌面背景路径属于用户数据 + args << "--exclude=/var/lib/AccountsService"; + // 此处不要break,因为还需要排除SYSTEM_RESTORE中的项 + case SystemRestoreScene::SYSTEM_RESTORE : // 还原工具不还原自身 args << "--exclude=/usr/bin/backup-daemon"; @@ -325,7 +348,13 @@ void UDiskSystemRestoreProxy::restoreSystem() { QString destPath = Utils::getSysRootPath(); - QStringList args = getRsyncArgs(SystemRestoreScene::SYSTEM_RESTORE); + QStringList args; + // 自动更新的备份还原时保留用户数据 + if (m_backupWrapper.m_type == BackupType::RESTORE_SYSTEM_WITH_DATA) { + args = getRsyncArgs(SystemRestoreScene::RESTORE_SYSTEM_WITH_DATA); + } else { + args = getRsyncArgs(SystemRestoreScene::SYSTEM_RESTORE); + } args << m_srcPath + "/"; destPath += "/"; diff --git a/backup-daemon/udisksystemrestoreproxy.h b/backup-daemon/udisksystemrestoreproxy.h index edb2f97..db83295 100755 --- a/backup-daemon/udisksystemrestoreproxy.h +++ b/backup-daemon/udisksystemrestoreproxy.h @@ -12,6 +12,7 @@ class UDiskSystemRestoreProxy : public Worker public: // 系统还原的几种场景 enum SystemRestoreScene { + RESTORE_SYSTEM_WITH_DATA, // 保留用户数据还原 SYSTEM_RESTORE, // 系统还原 EFI_RESTORE, // efi还原 };