feat: update backup script with cleanup logic
- Adjust the script to include logic for cleaning up old backups - Added support for handling PostgreSQL data directories - Ensure temporary directories are cleaned after use This update improves the backup process by ensuring that old backups are properly cleaned up to save storage space and enhance efficiency. It also includes logic to handle specific cases for PostgreSQL directories, providing a more robust backup operation.
This commit is contained in:
parent
437ce63585
commit
3c256f1575
@ -46,9 +46,8 @@ data:
|
|||||||
DIR_COUNT=$(find /data/local-csi -mindepth 1 -maxdepth 1 -type d | wc -l)
|
DIR_COUNT=$(find /data/local-csi -mindepth 1 -maxdepth 1 -type d | wc -l)
|
||||||
if [ "$DIR_COUNT" -eq 0 ]; then
|
if [ "$DIR_COUNT" -eq 0 ]; then
|
||||||
echo "目录 /data/local-csi 中没有子目录,退出备份"
|
echo "目录 /data/local-csi 中没有子目录,退出备份"
|
||||||
exit 0
|
# exit 0
|
||||||
fi
|
else
|
||||||
|
|
||||||
# 遍历所有目录
|
# 遍历所有目录
|
||||||
find /data/local-csi -mindepth 1 -maxdepth 1 -type d | while read dir; do
|
find /data/local-csi -mindepth 1 -maxdepth 1 -type d | while read dir; do
|
||||||
DIR_NAME=$(basename "$dir")
|
DIR_NAME=$(basename "$dir")
|
||||||
@ -109,6 +108,7 @@ data:
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
END_TIME=$(date +%s)
|
END_TIME=$(date +%s)
|
||||||
echo "备份完成"
|
echo "备份完成"
|
||||||
|
@ -23,6 +23,7 @@ spec:
|
|||||||
operator: NotIn
|
operator: NotIn
|
||||||
values:
|
values:
|
||||||
- vkvm-us2
|
- vkvm-us2
|
||||||
|
- aliyun-gz2
|
||||||
# - matchExpressions:
|
# - matchExpressions:
|
||||||
# #- key: region
|
# #- key: region
|
||||||
# # operator: NotIn
|
# # operator: NotIn
|
||||||
|
Loading…
Reference in New Issue
Block a user