增量式备份

This commit is contained in:
zhangkun9038@dingtalk.com 2023-07-15 23:46:25 +08:00
parent d76c0ecfc3
commit c1af7cb7b3

View File

@ -43,14 +43,11 @@ cd $backUpPath
# 更新上次备份的binlog文件名和位置 # 更新上次备份的binlog文件名和位置
echo "$CURRENT_BINLOG $CURRENT_POSITION" > "last_backup.txt" echo "$CURRENT_BINLOG $CURRENT_POSITION" > "last_backup.txt"
backup_files=() OLD_BACKUPS=()
for file in ${backUpPath}/${dbName}-incremental--*.sql.zip; do
cd $backUpPath file_date=$(echo "$file" | grep -oP "(?<=-$dbName-)\d{10}(?=.sql.zip)")
find ${dbName}-incremental-*.sql.zip -type f -print0 | while IFS= read -r -d '' file; do if [[ $((CURRENT_DATE - file_date)) -gt 600 ]]; then
file_date=$(stat -c %Y "$file") OLD_BACKUPS+=("$file")
current_time=$(date +%s)
if (( (current_time - file_date) > 86400 )); then
backup_files+=("$file")
fi fi
done done