From 38707a41e3376572be27329851b278d841e80be3 Mon Sep 17 00:00:00 2001 From: Ryan Parr Date: Fri, 19 Jan 2024 10:31:53 +0100 Subject: [PATCH] METAL-4521 METAL-4521 - Run `pg_dump` without compression. Instead, write a temporary file, compress that file, and rename the temporary file. --- entrypoint.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index e474159..60868c6 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,6 +4,7 @@ set -e echo "Prepare configuration for script" TIMESTAMP=$(date +%F_%R) START_TIMESTAMP=$(date +%s) +TEMP_FILE=temp.sql BACKUP_FILE=${DB_NAME}-${TIMESTAMP}.sql.gz BACKUP_FILE_LATEST=${DB_NAME}-latest.sql.gz DB_HOST=${DB_HOST:-localhost} @@ -26,7 +27,9 @@ gcloud auth activate-service-account --key-file=/srv/gcloud/credentials.json (umask 377 && echo *:5432:*:${DB_USER}:${DB_PASSWORD} >> ~/.pgpass) echo "Start create backup" -pg_dump -F c -Z 9 -h ${DB_HOST} -p 5432 -U ${DB_USER} ${DB_NAME} -f ${BACKUP_FILE} +pg_dump -Fc -Z0 -h ${DB_HOST} -p 5432 -U ${DB_USER} ${DB_NAME} -f ${TEMP_FILE} +gzip ${TEMP_FILE} +mv ${TEMP_FILE}.gz ${BACKUP_FILE} BACKUP_SIZE=$(du ${BACKUP_FILE} | awk '{print $1}') echo "End backup" @@ -50,4 +53,4 @@ cat <