fix backups and restore.

This commit is contained in:
Simon Larsen
2022-12-12 15:25:30 +05:30
parent c3d0fe4623
commit 955df684b6
5 changed files with 39 additions and 2 deletions

View File

@@ -1 +1,10 @@
docker run -it --rm --entrypoint sh debug/ubuntu
# This file takes last 30 days backup. Make sure you run this file atleast once/day.
# The backup will be in the format of db-(date of the month).backup
# Before the backup, please make sure DATABASE_BACKUP_* ENV vars in config.env is set properly.
export $(grep -v '^#' config.env | xargs)
sudo docker run -it --net=host --rm \
--env-file config.env \
--volume=$(pwd)$DATABASE_BACKUP_DIRECTORY:/var/lib/postgresql/data \
postgres:latest /usr/bin/pg_dump -Fc --dbname=postgresql://$DATABASE_BACKUP_USERNAME:$DATABASE_BACKUP_PASSWORD@$DATABASE_BACKUP_HOST:$DATABASE_BACKUP_PORT/$DATABASE_BACKUP_NAME --file=/var/lib/postgresql/data/db-$(date +%d).backup