自动备份点的grub还原记录日志优化

This commit is contained in:
zhaominyong 2022-07-29 10:55:16 +08:00
parent 71049c3e2b
commit 1781df3850
1 changed files with 8 additions and 1 deletions

View File

@ -961,6 +961,7 @@ getLastUsefulBackupPointUuid() {
currentType=true
lastUsefulBackupPointUuid=""
foundComment=0 #是否发现了要修改的comment
lastbackupname=""
#如果不定义IFS则echo $line会去掉前后空格导致写到文件中去时没有格式
IFS_old=$IFS
@ -969,6 +970,10 @@ getLastUsefulBackupPointUuid() {
#去除了前后空格
xxx=$(echo "$line" | sed "s/^[ \t]*//g" | sed "s/[ \t]*$//g")
#echo "xxx: $xxx"
if [[ "$xxx" =~ "<Comment>" ]]; then
lastbackupname=$xxx
fi
if [[ "$xxx" =~ "<Uuid>" ]]; then
currentUuid=$xxx
@ -1009,6 +1014,8 @@ getLastUsefulBackupPointUuid() {
lastUsefulBackupPointUuid=$(echo $lastUsefulBackupPointUuid | sed 's:<Uuid>::' | tr -d "\n")
lastUsefulBackupPointUuid=$(echo $lastUsefulBackupPointUuid | sed 's:</Uuid>.*::' | tr -d "\n")
#echo "lastUsefulBackupPointUuid=$lastUsefulBackupPointUuid"
lastbackupname=$(echo $lastbackupname | sed 's:<Comment>::' | tr -d "\n")
lastbackupname=$(echo $lastbackupname | sed 's:</Comment>.*::' | tr -d "\n")
}
#see backup-auto/autobackup.cpp
@ -1029,7 +1036,7 @@ restoreAuto() { #还原
fi
#写日志文件
local m_time=$(date "+%y-%m-%d %H:%M:%S" | tr -d "\n")
writeLogFile "${m_time},${uuid},4,grub系统还原" #grub时只有一键还原没有增量还原
writeLogFile "${m_time},${uuid},4,grub系统还原,,,${lastbackupname}" #grub时只有一键还原没有增量还原
restoreDir="${m_mountPath}${BACKUP}/snapshots/$uuid"