Add compressed PostgreSQL dump for each databases

This commit is contained in:
Eric Morino 2021-06-22 15:36:12 +02:00
parent 0090595d40
commit 31fb33adc4
1 changed files with 8 additions and 0 deletions

View File

@ -212,6 +212,7 @@ if [ "${LOCAL_TASKS}" = "1" ]; then
## Purge previous dumps
# rm ${LOCAL_BACKUP_DIR}/pg.*.gz
# rm ${LOCAL_BACKUP_DIR}/pg-backup.tar
# rm ${LOCAL_BACKUP_DIR}/postgresql/*
## example with pg_dumpall (warning: you need space in ~postgres)
# su - postgres -c "pg_dumpall > ~/pg.dump.bak"
# mv ~postgres/pg.dump.bak ${LOCAL_BACKUP_DIR}/
@ -226,6 +227,13 @@ if [ "${LOCAL_TASKS}" = "1" ]; then
## example with only TABLE1 and TABLE2 from MYBASE
# pg_dump -p 5432 -h 127.0.0.1 -U USER --clean -F t --inserts -f ${LOCAL_BACKUP_DIR}/pg-backup.tar -T 'TABLE1' -T 'TABLE2' MYBASE
## example with compressed PostgreSQL dump for each databases
# mkdir -p -m 700 ${LOCAL_BACKUP_DIR}/postgresql
# chown postgres:postgres ${LOCAL_BACKUP_DIR}/postgresql
# dbs=$(sudo -u postgres psql -U postgres -lt | awk -F\| '{print $1}' |grep -v template*)
#
# for databases in $dbs ; do sudo -u postgres /usr/bin/pg_dump --create -s -U postgres -d $databases | gzip --best -c > ${LOCAL_BACKUP_DIR}/postgresql/$databases.sql.gz ; done
## MongoDB
## don't forget to create use with read-only access