ansible/playbooks/rdiff-backup.yml

36 lines
2.1 KiB
YAML
Raw Normal View History

# all this does is use the ansible scheduler to allow you to fork off
# a set number of rdiff-backup runs against an array of backup targets
# Since rdiff-backup doesn't have its own built-in-scheduler
# this seemed like an obvious cheat
- name: rdiff-backup
hosts: backup_clients
user: root
gather_facts: False
2014-05-09 01:44:38 +00:00
serial: 10
# host_backup_targets set in host_vars or group_vars
# global_backup_targets can be defined in vars, group_vars/all or anywhere
2016-08-08 19:36:31 +00:00
# take the 'echo' out below for it to actually run
# FIXME - see how this copes with timeouts
# FIXME - storing/reporting results and output?
# FIXME - coping with errors?
vars:
- global_backup_targets: ['/etc', '/home']
tasks:
- name: run rdiff-backup hitting all the global targets
2016-07-18 19:03:17 +00:00
local_action: "shell rdiff-backup --remote-schema 'ssh -p {{ ansible_port|default(22) }} -C %s rdiff-backup --server' --create-full-path --print-statistics {{ inventory_hostname }}::{{ item }} /fedora_backups/{{ inventory_hostname }}/`basename {{ item }}` | mail -r sysadmin-backup-members@fedoraproject.org -s 'rdiff-backup: {{ inventory_hostname }}:{{ item }}' sysadmin-backup-members@fedoraproject.org"
2016-05-30 20:26:41 +00:00
with_items: '{{ global_backup_targets }}'
when: global_backup_targets is defined
- name: copy new database dumps into the backup server database dir
local_action: "shell rsync -a {{ inventory_hostname }}:{{ item }}/ /fedora_backups/databases/{{ inventory_hostname }}/"
with_items: '{{ db_backup_dir }}'
when: db_backup_dir is defined
- name: run rdiff-backup hitting all the host targets
2016-07-18 19:03:17 +00:00
local_action: "shell rdiff-backup --remote-schema 'ssh -p {{ ansible_port|default(22) }} -C %s rdiff-backup --server' --exclude='**git-seed*' --exclude='**git_seed' --exclude='**.snapshot' --create-full-path --print-statistics {{ inventory_hostname }}::{{ item }} /fedora_backups/{{ inventory_hostname }}/`basename {{ item }}` | mail -r sysadmin-backup-members@fedoraproject.org -s 'rdiff-backup: {{ inventory_hostname }}:{{ item }}' sysadmin-backup-members@fedoraproject.org"
2016-05-30 20:26:41 +00:00
with_items: '{{ host_backup_targets }}'
when: host_backup_targets is defined