From fff7fe9ae9efe4546ba3fb6ae04ad8ddbfbe187b Mon Sep 17 00:00:00 2001 From: zhaominyong Date: Tue, 25 Jan 2022 16:15:41 +0800 Subject: [PATCH] =?UTF-8?q?U=E7=9B=98=E8=BF=98=E5=8E=9F=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E7=94=A8=E6=88=B7=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backup-daemon/systemrestoreproxy.cpp | 2 ++ backup-daemon/udisksystemrestoreproxy.cpp | 31 ++++++++++++++++++++++- backup-daemon/udisksystemrestoreproxy.h | 1 + 3 files changed, 33 insertions(+), 1 deletion(-) 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还原 };