Files
baserow/backup-postgres.sh
2025-11-10 18:15:59 -05:00

22 lines
645 B
Bash

if [ "$1" == "pre-backup" ]; then
# Remove any existing db dump and then create a new one
rm -rf $DATA_DIR/postgres/postgres-backup
source /baserow/data/.pgpass
PGPASSWORD=$DATABASE_PASSWORD pg_dump -j 8 -h localhost -U baserow baserow --format=directory -f $DATA_DIR/postgres/postgres-backup
exit
fi
if [ "$1" == "post-backup" ]; then
rm -rf $DATA_DIR/postgres/postgres-backup
exit
fi
if [ "$1" == "pre-restore" ]; then
exit
fi
if [ "$1" == "post-restore" ]; then
source /baserow/data/.pgpass
PGPASSWORD=$DATABASE_PASSWORD pg_restore -j 8 -h localhost -U baserow -d baserow -c $DATA_DIR/postgres/postgres-backup
exit
fi