mirror of
https://gitlab.archlinux.org/archlinux/infrastructure.git
synced 2025-01-18 08:06:16 +01:00
Move backup-related variable defaults from the database roles into the borg_client role. Also check group membership to guard installation of database backup helper scripts.
20 lines
666 B
Django/Jinja
20 lines
666 B
Django/Jinja
#!/bin/bash
|
|
#
|
|
# Script to backup all postgres databases individually
|
|
#
|
|
# Requires local login with `postgres` user and either trusted or peer auth.
|
|
|
|
set -e
|
|
|
|
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 {{ backup_postgres_dir }}";
|
|
sudo -u postgres pg_dump --serializable-deferrable -Fc "$db" > "{{ backup_postgres_dir }}/$db.dump"
|
|
done
|
|
|
|
echo "Dumping globals to {{ backup_postgres_dir }}"
|
|
sudo -u postgres pg_dumpall --globals-only > "{{ backup_postgres_dir }}/globals.sql.dump"
|