infrastructure/playbooks/roles/backup/files/hooks/postgresql

17 lines
373 B
Text
Raw Normal View History

2024-10-05 23:59:46 +00:00
#!/usr/bin/env bash
cd "$1"
2024-09-26 22:02:36 +00:00
postgres_tables=$(sudo -u postgres psql -Atc "SELECT datname FROM pg_database WHERE datistemplate = false;")
for i in $postgres_tables
do
printf "dumping %s ..." "$i"
sudo -u postgres pg_dump "$i" | gzip >"pg_dump_$i.sql.gz"
echo " done"
done
2024-10-31 01:25:02 +00:00
echo -n "dumping all ..."
2024-09-26 22:02:36 +00:00
sudo -u postgres pg_dumpall | gzip >"pg_dumpall.sql.gz"
2024-10-31 01:25:02 +00:00
echo " done"