added backup support
This commit is contained in:
parent
b8f4b6d206
commit
78231abc44
3 changed files with 27 additions and 21 deletions
21
tasks/backup.yml
Normal file
21
tasks/backup.yml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
- name: add postgresql backup folder
|
||||
file:
|
||||
path: /opt/postgresbackup/
|
||||
state: directory
|
||||
owner: postgres
|
||||
group: postgres
|
||||
mode: '750'
|
||||
|
||||
- name: add backup cronjob for easier backup/restore
|
||||
cron:
|
||||
name: db backup
|
||||
job: '/usr/bin/pg_dumpall | gzip > /opt/postgresbackup/$(date "+\%Y\%m\%d-\%H\%M.sql.gz")'
|
||||
user: postgres
|
||||
hour: "*/4"
|
||||
minute: 45
|
||||
|
||||
- name: add backup cleanup cronjob
|
||||
cron:
|
||||
name: db backup cleanup
|
||||
job: 'find /opt/postgresbackup/* -mtime +{{ postgresql.backup.keep_days }} -type f -exec rm {} \;'
|
||||
special_time: daily
|
||||
Loading…
Add table
Add a link
Reference in a new issue