Try and make a public anitya dump with the right tables.

This commit is contained in:
Kevin Fenzi 2018-10-08 17:40:46 +00:00
parent f8e4394a87
commit f0c596c427
5 changed files with 46 additions and 1 deletions

View file

@ -0,0 +1,16 @@
#!/bin/bash
# Backup a database *locally* to /backups/.
# Sleep a bit so we do not have a thundering herd on db hosts
sleep $[ ( $RANDOM % 7200 ) + 1 ]s
DB=anitya
# Make our latest backup
# Make it use a limited number of threads because pxz will use all the
# cpus which causes pg_dump to starve which causes...
/usr/bin/pg_dump -T users -T tokens -T 'social*' -T sessions -C $DB | /usr/bin/pxz -T4 > /backups/$DB-public-$(date +%F).dump.xz
# Also, delete the backup from a few days ago.
rm -f /backups/$DB-public-$(date --date="1 days ago" +%F).dump.xz

View file

@ -0,0 +1 @@
0 0 * * * postgres /usr/local/bin/backup-database.anitya

View file

@ -84,6 +84,18 @@
tags:
- postgresql
- name: Copy over anitya public backup scriplet
copy: src=backup-database.anitya dest=/usr/local/bin/backup-database.anitya mode=0755
tags:
- postgresql
when: inventory_hostname.startswith('db01.phx2')
- name: Copy over anitya publib backup cron
copy: src=cron-backup-anitya-public dest=/etc/cron.d/cron-backup-anitya-public mode=0755
tags:
- postgresql
when: inventory_hostname.startswith('db01.phx2')
- name: Set up some cronjobs to backup databases as configured
template: >
src=cron-backup-database

View file

@ -0,0 +1,16 @@
#!/bin/bash
# Backup a database *locally* to /backups/.
# Sleep a bit so we do not have a thundering herd on db hosts
sleep $[ ( $RANDOM % 7200 ) + 1 ]s
DB=$1
# Make our latest backup
# Make it use a limited number of threads because pxz will use all the
# cpus which causes pg_dump to starve which causes...
/usr/bin/pg_dump --exclude-table-data=sessions -C $DB | /usr/bin/pxz -T4 > /backups/$DB-$(date +%F).dump.xz
# Also, delete the backup from a few days ago.
rm -f /backups/$DB-$(date --date="1 days ago" +%F).dump.xz

View file

@ -10,7 +10,7 @@ scp db01.phx2.fedoraproject.org:/backups/pkgdb2-$(date +%F).dump.xz /srv/web/inf
scp db01.phx2.fedoraproject.org:/backups/koschei-$(date +%F).dump.xz /srv/web/infra/db-dumps/koschei.dump.xz
scp db01.phx2.fedoraproject.org:/backups/bodhi2-$(date +%F).dump.xz /srv/web/infra/db-dumps/bodhi2.dump.xz
scp db01.phx2.fedoraproject.org:/backups/pdc-$(date +%F).dump.xz /srv/web/infra/db-dumps/pdc.dump.xz
scp db01.phx2.fedoraproject.org:/backups/anitya-$(date +%F).dump.xz /srv/web/infra/db-dumps/anitya.dump.xz
scp db01.phx2.fedoraproject.org:/backups/anitya-public-$(date +%F).dump.xz /srv/web/infra/db-dumps/anitya.dump.xz
scp db01.phx2.fedoraproject.org:/backups/mailman-$(date +%F).dump.xz /srv/web/infra/db-dumps/mailman.dump.xz
scp db01.phx2.fedoraproject.org:/backups/mbs-$(date +%F).dump.xz /srv/web/infra/db-dumps/mbs.dump.xz
scp db01.phx2.fedoraproject.org:/backups/odcs-$(date +%F).dump.xz /srv/web/infra/db-dumps/odcs.dump.xz