Move postgres backup cron task inside a bash flavored script.
This commit is contained in:
parent
a41fb3da66
commit
5e32fe5643
3 changed files with 10 additions and 1 deletions
6
roles/postgresql_server/files/backup-database
Normal file
6
roles/postgresql_server/files/backup-database
Normal file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
# Backup a database *locally* to /backups/.
|
||||
|
||||
DB=$1
|
||||
|
||||
/usr/bin/pg_dump -C $DB | /usr/bin/xz > /backups/$DB-$(date +%F).dump.xz
|
|
@ -36,6 +36,9 @@
|
|||
- name: Ensure postgres has a place to backup to
|
||||
file: dest=/backups state=directory owner=postgres
|
||||
|
||||
- name: Copy over backup scriplet
|
||||
copy: src=backup-database dest=/usr/local/bin/backup-database mode=0755
|
||||
|
||||
- name: Set up some cronjobs to backup databases as configured
|
||||
template: >
|
||||
src=cron-backup-database
|
||||
|
|
|
@ -1 +1 @@
|
|||
0 0 * * * postgres /usr/bin/pg_dump -C {{ item }} | /usr/bin/xz > /backups/{{ item }}-$(date +%F).dump.xz
|
||||
0 0 * * * postgres /usr/local/bin/backup-database {{ item }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue