diff --git a/backup-daemon/data/backup-auto-efi b/backup-daemon/data/backup-auto-efi index b04c007..55dbcdb 100755 --- a/backup-daemon/data/backup-auto-efi +++ b/backup-daemon/data/backup-auto-efi @@ -594,17 +594,17 @@ generateExcludeFile() { #echo "/data/*" >>$EXCLUDEFILE #用户可以把数据放到该分区或者目录 #是否覆盖备份还原工具自身,因为grub备份还原使用的工具是initrd.img里面的东西,故不存在时可以还原备份还原工具本身(例如工具被删除的场景) - if [ $backupOrRestore -eq 1 ]; then - bFileExists "/usr/bin/backup-daemon" - bFileExists "/usr/bin/kybackup" - bFileExists "/usr/bin/backup-auto" - bFileExists "/usr/bin/mount_fstab_efi" - bFileExists "/usr/bin/backup-auto-efi" - bFileExists "/usr/bin/rsync" - bFileExists "/usr/share/rsync" - bFileExists "/usr/share/initramfs-tools/hooks/kybackup-hooks" - bFileExists "/usr/share/initramfs-tools/scripts/local-bottom/kybackup" - fi + #if [ $backupOrRestore -eq 1 ]; then + # bFileExists "/usr/bin/backup-daemon" + # bFileExists "/usr/bin/kybackup" + # bFileExists "/usr/bin/backup-auto" + # bFileExists "/usr/bin/mount_fstab_efi" + # bFileExists "/usr/bin/backup-auto-efi" + # bFileExists "/usr/bin/rsync" + # bFileExists "/usr/share/rsync" + # bFileExists "/usr/share/initramfs-tools/hooks/kybackup-hooks" + # bFileExists "/usr/share/initramfs-tools/scripts/local-bottom/kybackup" + #fi # 安全模块会将文件/usr/share/kysec-utils/data/readonly_list中的文件列表限制只读,无法修改、备份(包含扩展属性时)、删除等 # 现在里面仅有/etc/uid_list,先暂时排除掉;等后续安全模块有其它保护方案后再进一步修改 @@ -1050,7 +1050,7 @@ restoreAuto() { #还原 fi #0:backup 1:restore - generateExcludeFile 1 + #generateExcludeFile 1 echo "Begin to restore efi directory..." >>$PLOGFILE echo "Begin to restore efi directory..." #额外排除目录或文件 @@ -1076,13 +1076,27 @@ restoreAuto() { #还原 #保留用户数据还原 if [[ x${m_isRetainUserData} = x"true" ]]; then # 用户数据目录或文件 - bFileExists "/var/lib/biometric-auth" - bFileExists "/data/sec_storage_data" - bFileExists "/etc/passwd" - bFileExists "/etc/shadow" - bFileExists "/etc/group" - bFileExists "/etc/gshadow" - bFileExists "/etc/sudoers" + if [ -e "${rootpath}/var/lib/biometric-auth" ]; then + excludes="${excludes} --exclude=/var/lib/biometric-auth" + fi + if [ -e "${rootpath}/data/sec_storage_data" ]; then + excludes="${excludes} --exclude=/data/sec_storage_data" + fi + if [ -e "${rootpath}/etc/passwd" ]; then + excludes="${excludes} --exclude=/etc/passwd" + fi + if [ -e "${rootpath}/etc/shadow" ]; then + excludes="${excludes} --exclude=/etc/shadow" + fi + if [ -e "${rootpath}/etc/group" ]; then + excludes="${excludes} --exclude=/etc/group" + fi + if [ -e "${rootpath}/etc/gshadow" ]; then + excludes="${excludes} --exclude=/etc/gshadow" + fi + if [ -e "${rootpath}/etc/sudoers" ]; then + excludes="${excludes} --exclude=/etc/sudoers" + fi excludes="${excludes} --exclude=/home --exclude=/root --exclude=/data/home --exclude=/data/root --exclude=/var/lib/AccountsService" #如果是990,排除/data;否则,排除/data/usershare @@ -1093,10 +1107,18 @@ restoreAuto() { #还原 fi #如果是出厂备份的还原,还需要保留语言和时区配置 if [[ ${uuid} = "{${factory_uuid}}" && x${is_990_9a0} != x"true" ]]; then - bFileExists "/etc/localtime" - bFileExists "/usr/share/zoneinfo" - bFileExists "/etc/default/locale" - bFileExists "/usr/share/i18n" + if [ -e "${rootpath}/etc/localtime" ]; then + excludes="${excludes} --exclude=/etc/localtime" + fi + if [ -e "${rootpath}/usr/share/zoneinfo" ]; then + excludes="${excludes} --exclude=/usr/share/zoneinfo" + fi + if [ -e "${rootpath}/etc/default/locale" ]; then + excludes="${excludes} --exclude=/etc/default/locale" + fi + if [ -e "${rootpath}/usr/share/i18n" ]; then + excludes="${excludes} --exclude=/usr/share/i18n" + fi fi fi # 兼容以前的老备份数据,后面可以尝试去掉此条件的逻辑