diff --git a/site-modules/profile/manifests/postgresql/backup.pp b/site-modules/profile/manifests/postgresql/backup.pp index 2bbf7b9e..a67c8aaa 100644 --- a/site-modules/profile/manifests/postgresql/backup.pp +++ b/site-modules/profile/manifests/postgresql/backup.pp @@ -1,15 +1,15 @@ class profile::postgresql::backup { include profile::postgresql::client - $pg_backup_user = %{hiera('swh::deploy::db::pgbouncer::user::login')} - $pg_backup_password = %{hiera('swh::deploy::db::pgbouncer::user::password')} + $pg_backup_user = lookup('swh::deploy::db::pgbouncer::user::login') + $pg_backup_password = lookup('swh::deploy::db::pgbouncer::user::password') file { '/usr/local/bin/pg_cluster_backup.sh': ensure => file, owner => root, group => staff, mode => '0755', content => template('profile/swh/pg_cluster_backup.sh.erb'), } } diff --git a/site-modules/profile/templates/swh/pg_cluster_backup.sh.erb b/site-modules/profile/templates/swh/pg_cluster_backup.sh.erb index d85c3283..d3190ac5 100755 --- a/site-modules/profile/templates/swh/pg_cluster_backup.sh.erb +++ b/site-modules/profile/templates/swh/pg_cluster_backup.sh.erb @@ -1,23 +1,26 @@ #!/bin/sh +TARGET_DIR=/srv/storage/space/postgres_secondary + # banco has many *slow* CPU cores +# A full backup of the secondary cluster takes ~= 40 minutes with p=3 and c=1 PARALLELISM=3 COMPRESSION=1 DATE=`/bin/date +%Y-%m-%d` export PGHOST=belvedere.internal.softwareheritage.org export PGPORT=5434 export PGUSER=<%= @pg_backup_user %> export PGPASSWORD=<%= @pg_backup_password %> DB_LIST=`/usr/bin/psql template1 -t -c \ "SELECT datname from pg_database WHERE datname NOT IN ('postgres', 'template0', 'template1');"` cd ${TARGET_DIR} for database in ${DB_LIST} do echo "dumping database ${database}" /usr/bin/pg_dump -Fd -j ${PARALLELISM} -Z ${COMPRESSION} -f pgdump-${DATE}.${database} -d ${database} -w done