132570 【备份还原】在备份还原工具中查看到出场备份有17G,但df -h查看backup只使用了9G
This commit is contained in:
parent
ae545075fc
commit
cc21b2d23b
|
@ -33,6 +33,8 @@ fi
|
|||
|
||||
m_backuplistPath=${m_mountPath}${BACKUP}"/snapshots/backuplist.xml"
|
||||
EXCLUDEFILE=${m_mountPath}${BACKUP}"/snapshots/.exclude"
|
||||
PLOGFILEDIR="${m_mountPath}${BACKUP}/log"
|
||||
PLOGFILE="$PLOGFILEDIR/log-$(date +%Y%m%d%H%M)"
|
||||
LOGFILE="/backup"${BACKUP}"/log.txt" #LOGFILE="/tmp/log.txt"
|
||||
|
||||
#是否是出厂备份
|
||||
|
@ -121,6 +123,19 @@ mountBackup()
|
|||
|
||||
mount $myuuid $m_mountPath
|
||||
|
||||
mkdir -p $PLOGFILEDIR
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Could not create log directory in /backup"
|
||||
exit 22
|
||||
fi
|
||||
|
||||
touch $PLOGFILE
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Could not create log file"
|
||||
exit 23
|
||||
fi
|
||||
echo "Log for backuping and restoring...." >$PLOGFILE
|
||||
|
||||
createBackupList #创建备份信息
|
||||
}
|
||||
|
||||
|
@ -208,6 +223,14 @@ is_remote(){
|
|||
fi
|
||||
}
|
||||
|
||||
function caculateDirSize() {
|
||||
mkdir -p /backup/snapshots/check/data
|
||||
local total_file_size=$(rsync -aAHXrn --stats --ignore-missing-args --exclude=/backup --exclude=/cdrom --exclude=/dev --exclude=/efi --exclude=/etc/uid_list --exclude=/data/ghost --exclude=/ghost --exclude=/lost+found --exclude=/media --exclude=/mnt --exclude=/proc --exclude=/run --exclude=/swap_file --exclude=/sys --exclude=/tmp --exclude=/var/lib/docker/overlay2 --exclude=/var/lib/kmre/data --exclude=/var/lib/kmre/kmre-*-*/data/media/0/0-麒麟* --exclude=/var/lib/udisks2 --exclude=/var/log --exclude=*/backup/snapshots --exclude=/data/home --exclude=/data/root "${rootpath}/" /backup/snapshots/check/data/ | grep "Total file size:" | awk '{print $4}' | sed 's/,//g')
|
||||
total_file_size=$(expr ${total_file_size} + 200000000)
|
||||
echo "备份所需空间大小:${total_file_size}" >>$PLOGFILE
|
||||
echo "${total_file_size}"
|
||||
}
|
||||
|
||||
#parameters: 无
|
||||
#返回值:(system_totalSize system_freeDisk system_usedDisk)
|
||||
caculateSystemSize(){
|
||||
|
@ -257,7 +280,8 @@ caculateSystemSize(){
|
|||
continue
|
||||
fi
|
||||
|
||||
#echo $line
|
||||
echo $line
|
||||
echo $line >>$PLOGFILE
|
||||
|
||||
device=$( echo "$line"|awk '{print $1}')
|
||||
mntdir=$( echo "$line"|awk '{print $2}')
|
||||
|
@ -363,7 +387,8 @@ checkBackupCapacity() { #(m_rootPath.toStdString().c_str(), retstatus))
|
|||
system_freeDisk=${result[1]}
|
||||
system_usedDisk=${result[2]}
|
||||
|
||||
global_system_usedDisk=$system_usedDisk
|
||||
#global_system_usedDisk=$system_usedDisk
|
||||
global_system_usedDisk=$(caculateDirSize)
|
||||
|
||||
#echo "--system_totalSize="$system_totalSize
|
||||
#echo "--system_freeDisk="$system_freeDisk
|
||||
|
@ -403,10 +428,11 @@ checkBackupCapacity() { #(m_rootPath.toStdString().c_str(), retstatus))
|
|||
exit 403
|
||||
fi
|
||||
|
||||
echo "bybobbi: bakup_freeDisk is " $backup_freeDisk
|
||||
echo "bybobbi: system_usedDisk is " $system_usedDisk
|
||||
|
||||
if [ "$backup_freeDisk" -gt "$system_usedDisk" ]; then
|
||||
#echo "bybobbi: bakup_freeDisk is " $backup_freeDisk
|
||||
#echo "bybobbi: system_usedDisk is " $system_usedDisk
|
||||
echo "free size : $backup_freeDisk; sys_size : $global_system_usedDisk"
|
||||
echo "free size : $backup_freeDisk; sys_size : $global_system_usedDisk" >>$PLOGFILE
|
||||
if [ ${backup_freeDisk} -gt ${global_system_usedDisk} ]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
|
|
|
@ -250,7 +250,7 @@ is_remote() {
|
|||
|
||||
function caculateDirSize() {
|
||||
mkdir -p /backup/snapshots/check/data
|
||||
local total_file_size=$(rsync -aAHXrn --stats --ignore-missing-args --exclude=/backup --exclude=/cdrom --exclude=/dev --exclude=/efi --exclude=/etc/uid_list --exclude=/data/ghost --exclude=/ghost --exclude=/lost+found --exclude=/media --exclude=/mnt --exclude=/proc --exclude=/run --exclude=/swap_file --exclude=/sys --exclude=/tmp --exclude=/var/lib/docker/overlay2 --exclude=/var/lib/kmre/data --exclude=/var/lib/kmre/kmre-*-*/data/media/0/0-麒麟* --exclude=/var/lib/udisks2 --exclude=/var/log --exclude=*/backup/snapshots --exclude=/data/home --exclude=/data/root --exclude=/home/zhaominyong/.box --exclude=/data/home/zhaominyong/.box --exclude=/data "${rootpath}/" /backup/snapshots/check/data/ | grep "Total file size:" | awk '{print $4}' | sed 's/,//g')
|
||||
local total_file_size=$(rsync -aAHXrn --stats --ignore-missing-args --exclude=/backup --exclude=/cdrom --exclude=/dev --exclude=/efi --exclude=/etc/uid_list --exclude=/data/ghost --exclude=/ghost --exclude=/lost+found --exclude=/media --exclude=/mnt --exclude=/proc --exclude=/run --exclude=/swap_file --exclude=/sys --exclude=/tmp --exclude=/var/lib/docker/overlay2 --exclude=/var/lib/kmre/data --exclude=/var/lib/kmre/kmre-*-*/data/media/0/0-麒麟* --exclude=/var/lib/udisks2 --exclude=/var/log --exclude=*/backup/snapshots --exclude=/data/home --exclude=/data/root "${rootpath}/" /backup/snapshots/check/data/ | grep "Total file size:" | awk '{print $4}' | sed 's/,//g')
|
||||
total_file_size=$(expr ${total_file_size} + 200000000)
|
||||
echo "备份所需空间大小:${total_file_size}" >>$PLOGFILE
|
||||
echo "${total_file_size}"
|
||||
|
|
Loading…
Reference in New Issue