From 3e866e0aab7142062c10d6a607952e645d112347 Mon Sep 17 00:00:00 2001 From: Delio Castillo Date: Tue, 21 Jun 2016 12:29:23 -0700 Subject: [PATCH] makes the database backups compressed. restores compressed backups --- {{cookiecutter.project_slug}}/compose/postgres/backup.sh | 4 ++-- {{cookiecutter.project_slug}}/compose/postgres/restore.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.project_slug}}/compose/postgres/backup.sh b/{{cookiecutter.project_slug}}/compose/postgres/backup.sh index 97c95e1d..47f7a514 100644 --- a/{{cookiecutter.project_slug}}/compose/postgres/backup.sh +++ b/{{cookiecutter.project_slug}}/compose/postgres/backup.sh @@ -16,7 +16,7 @@ export PGPASSWORD=$POSTGRES_PASSWORD echo "creating backup" echo "---------------" -FILENAME=backup_$(date +'%Y_%m_%dT%H_%M_%S').sql -pg_dump -h postgres -U $POSTGRES_USER >> /backups/$FILENAME +FILENAME=backup_$(date +'%Y_%m_%dT%H_%M_%S').sql.gz +pg_dump -h postgres -U $POSTGRES_USER | gzip > /backups/$FILENAME echo "successfully created backup $FILENAME" diff --git a/{{cookiecutter.project_slug}}/compose/postgres/restore.sh b/{{cookiecutter.project_slug}}/compose/postgres/restore.sh index 75008280..0ac8d1e0 100644 --- a/{{cookiecutter.project_slug}}/compose/postgres/restore.sh +++ b/{{cookiecutter.project_slug}}/compose/postgres/restore.sh @@ -53,4 +53,4 @@ createdb -h postgres -U $POSTGRES_USER $POSTGRES_USER -O $POSTGRES_USER # restore the database echo "restoring database $POSTGRES_USER" -psql -h postgres -U $POSTGRES_USER < $BACKUPFILE +gunzip -c $BACKUPFILE | psql -h postgres -U $POSTGRES_USER