Skip to content

Commit

Permalink
METAL-4521 METAL-4521 - Run pg_dump without compression.
Browse files Browse the repository at this point in the history
Instead, write a temporary file, compress that file, and rename the
temporary file.
  • Loading branch information
ryanparr-kci committed Jan 19, 2024
1 parent df88cfa commit 38707a4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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"

Expand All @@ -50,4 +53,4 @@ cat <<EOF | curl -s --data-binary @- http://${PROMETHEUS_PUSH_GATEWAY}/metrics/j
# HELP ${PROM_NAMESPACE}_backup_size Backup Size in bytes
${PROM_NAMESPACE}_backup_size $BACKUP_SIZE
EOF
fi
fi

0 comments on commit 38707a4

Please sign in to comment.