Skip to content

Commit

Permalink
chore: improve archive wal log (#1330)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyelei authored Dec 17, 2024
1 parent dd2ffa3 commit 6ee4324
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion addons/mysql/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ image:
xtraBackup:
# if the value of image.xtraBackup.registry is not specified using `--set`, it will be set to the value of 'image.registry' by default
registry: ""
repository: apecloud/xtrabackup
repository: apecloud/percona-xtrabackup
syncer:
repository: apecloud/syncer
tag: 0.3.8
Expand Down
32 changes: 31 additions & 1 deletion addons/postgresql/dataprotection/postgresql-pitr-backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,38 @@ function check_pg_process() {
fi
}

function uploadMissingLogs() {
DP_log "start to upload the wal log which maybe misses"
local TODAY_INCR_LOG=$(date +%Y%m%d)
cd ${LOG_DIR}
uploadedLogs=$(datasafed list -f --recursive / -o json | jq -s -r '.[] | sort_by(.mtime) | .[] | .path')
if [[ -z ${uploadedLogs} ]]; then
return
fi
OLDEST_FILE=$(echo $uploadedLogs | awk '{print $1}')
OLDEST_FILE=$(basename $OLDEST_FILE)
DP_log "oldest uploaded wal: ${OLDEST_FILE}"
for i in $(find ./archive_status -type f | sort | grep .done); do
wal_done_name=$(basename ${i})
wal_name=${wal_done_name%.*}
if [[ "$wal_name" < "$OLDEST_FILE" ]]; then
continue
fi
if echo "$uploadedLogs" | grep -qE "${wal_name}\.(zst|partial\.zst)";then
continue
fi
if [ -f ${wal_name} ]; then
DP_log "upload ${wal_name}"
datasafed push -z zstd ${wal_name} "/${TODAY_INCR_LOG}/${wal_name}.zst"
fi
done
save_backup_status
}

# trap term signal
trap "echo 'Terminating...' && upload_wal_log && save_backup_status && sync && exit 0" TERM
trap "echo 'Terminating...' && sync && exit 0" TERM
uploadMissingLogs

DP_log "start to archive wal logs"
while true; do

Expand Down

0 comments on commit 6ee4324

Please sign in to comment.