From eee99952480af4386b890e38411c8d2fb4c6ffd8 Mon Sep 17 00:00:00 2001 From: skobkin Date: Wed, 6 Nov 2024 18:40:00 +0000 Subject: [PATCH] postgresql_backup. Using highest available level of compression. --- postgresql_backup/pg_backup.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/postgresql_backup/pg_backup.sh b/postgresql_backup/pg_backup.sh index fae5843..221c0c2 100644 --- a/postgresql_backup/pg_backup.sh +++ b/postgresql_backup/pg_backup.sh @@ -54,9 +54,11 @@ for PREFIX in $DATABASE_PREFIXES; do # Perform the backup based on the specified format if [[ "$DUMP_FORMAT" == "custom" ]]; then - pg_dump -h "$HOST" -p "$PORT" -U "$USER" -Fc "$DB_NAME" -f "$BACKUP_FILE" + # Custom format and highest ZSTD compression level + pg_dump -h "$HOST" -p "$PORT" -U "$USER" -Fc --compress="zstd:21" "$DB_NAME" -f "$BACKUP_FILE" elif [[ "$DUMP_FORMAT" == "sql" ]]; then - pg_dump -h "$HOST" -p "$PORT" -U "$USER" "$DB_NAME" | gzip > "$BACKUP_FILE" + # Plain-text SQL backup compressed with gzip at high compression level + pg_dump -h "$HOST" -p "$PORT" -U "$USER" "$DB_NAME" | gzip -9 > "$BACKUP_FILE" else echo "Invalid DUMP_FORMAT for $PREFIX: $DUMP_FORMAT. Skipping..." continue