You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
660 B
Django/Jinja
19 lines
660 B
Django/Jinja
#!/bin/bash
|
|
#
|
|
# Script to backup all postgres databases individually
|
|
#
|
|
# Requires local login with `postgres` user and either trusted or peer auth.
|
|
#
|
|
|
|
DBLIST=($(sudo -u postgres psql -d postgres -qt -c 'SELECT datname from pg_database'))
|
|
for db in "${DBLIST[@]}"; do
|
|
if [[ $db =~ template[01] ]]; then
|
|
continue;
|
|
fi
|
|
echo "Dumping $db to {{ postgres_backup_dir }}";
|
|
sudo -u postgres pg_dump --serializable-deferrable -Fc "$db" > "{{ postgres_backup_dir }}/$db.dump"
|
|
done
|
|
|
|
echo "Dumping globals to {{ postgres_backup_dir }}"
|
|
sudo -u postgres pg_dumpall --globals-only > "{{ postgres_backup_dir }}/globals.sql.dump"
|