mirror of
https://pagure.io/fedora-infra/ansible.git
synced 2026-03-20 03:57:02 +08:00
db-koji02: make sure backup uses all cpus
Signed-off-by: Kevin Fenzi <kevin@scrye.com>
This commit is contained in:
committed by
Pierre-Yves Chibon
parent
4c85106614
commit
bd50c6e4bc
16
roles/postgresql_server/files/backup-database.db-koji02
Normal file
16
roles/postgresql_server/files/backup-database.db-koji02
Normal 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 -T24 > /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
|
||||
@@ -105,6 +105,12 @@
|
||||
tags:
|
||||
- postgresql
|
||||
|
||||
- name: Copy over backup scriplet
|
||||
copy: src=backup-database dest=/usr/local/bin/backup-database mode=0755
|
||||
when: not inventory_hostname.startswith('db-koji02')
|
||||
tags:
|
||||
- postgresql
|
||||
|
||||
- name: Copy over backup scriplet
|
||||
copy: src=backup-database dest=/usr/local/bin/backup-database mode=0755
|
||||
when: inventory_hostname.startswith('db-koji02')
|
||||
|
||||
Reference in New Issue
Block a user