infrastructure/playbooks/roles/backup/files/hooks/postgresql
Tobias Reisinger 4104057771
Fix pre-commit hooks and move directories
roles/ and inventory/ are now in playbooks/
also fixed issues reported by ansible-lint
2024-10-14 18:31:36 +02:00

15 lines
353 B
Bash
Executable file

#!/usr/bin/env bash
cd "$1"
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
echo "dumping all"
sudo -u postgres pg_dumpall | gzip >"pg_dumpall.sql.gz"