feat: add source size calculation to backup script

- Introduce SOURCE_SIZE variable in cm-script.yaml
- Remove redundant SOURCE_SIZE calculation

This change calculates the size of the data directory
prior to initiating the backup process. It ensures that
the backup script has accurate information about the size
of the source data, enhancing the logging and monitoring
of backup activities.
This commit is contained in:
songtianlun 2025-04-22 22:19:16 +08:00
parent 53347b6ca6
commit 1e60ca2eb6

View File

@ -21,6 +21,7 @@ data:
HOSTNAME="${NODE_NAME:-$HOSTNAME}"
FEISHU_WEBHOOK_URL=$(cat /etc/feishu-webhook/url)
SOURCE_SIZE=$(du -sh /data/local-csi | cut -f1)
START_TIME=$(date +%s)
@ -54,7 +55,6 @@ data:
TIMESTAMP=$(date +%Y-%m-%d-%H-%M-%S)
BACKUP_NAME="backup-${DIR_NAME}-${TIMESTAMP}.tar.gz"
BACKUP_PATH="/tmp/${BACKUP_NAME}"
SOURCE_SIZE=$(du -sh /data/local-csi | cut -f1)
echo "正在备份目录: $dir"