Skip to content

Commit

Permalink
chore: backup postgresql with zstd instead of gzip (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
zjx20 authored Jan 3, 2024
1 parent 7b111cd commit 876fa41
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addons/postgresql/dataprotection/pg-basebackup-backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export PGPASSWORD=${DP_DB_PASSWORD}
trap handle_exit EXIT

START_TIME=`get_current_time`
echo ${DP_DB_PASSWORD} | pg_basebackup -Ft -Pv -c fast -Xf -D - -h ${DP_DB_HOST} -U ${DP_DB_USER} -W | gzip | datasafed push - "/${DP_BACKUP_NAME}.tar.gz"
echo ${DP_DB_PASSWORD} | pg_basebackup -Ft -Pv -c fast -Xf -D - -h ${DP_DB_HOST} -U ${DP_DB_USER} -W | datasafed push -z zstd - "/${DP_BACKUP_NAME}.tar.zst"

# stat and save the backup information
stat_and_save_backup_info $START_TIME
7 changes: 7 additions & 0 deletions addons/postgresql/dataprotection/pg-basebackup-restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ function remote_file_exists() {

mkdir -p ${DATA_DIR};

if [ $(remote_file_exists "${DP_BACKUP_NAME}.tar.zst") == "true" ]; then
datasafed pull -d zstd "${DP_BACKUP_NAME}.tar.zst" - | tar -xvf - -C "${DATA_DIR}/"
echo "done!";
exit 0
fi

# for compatibility
if [ $(remote_file_exists "${DP_BACKUP_NAME}.tar.gz") == "true" ]; then
datasafed pull "${DP_BACKUP_NAME}.tar.gz" - | gunzip | tar -xvf - -C "${DATA_DIR}/"
echo "done!";
Expand Down

0 comments on commit 876fa41

Please sign in to comment.