system-config/playbooks/roles/backup/tasks/main.yaml

58 lines
1.2 KiB
YAML

- name: Generate bup username for this host
set_fact:
bup_username: 'bup-{{ inventory_hostname.split(".", 1)[0] }}'
when: bup_username is not defined
- debug:
var: bup_username
- name: Install bup
package:
name:
- bup
state: absent
- name: Remove old keypair
file:
path: /root/.ssh/id_backup_ed25519
state: absent
- name: Remove old keypair
file:
path: /root/.ssh/id_backup_ed25519.pub
state: absent
- name: Remove old config directory
file:
path: /root/.bup
state: absent
- name: Remove ssh config
blockinfile:
path: /root/.ssh/config
state: absent
create: false
block: |
Host {{ item }}
HostName {{ item }}
IdentityFile /root/.ssh/id_backup_ed25519
User {{ bup_username }}
mode: 0600
with_inventory_hostnames: backup-server
ignore_errors: True
- name: Remove /etc/bup-excludes
file:
path: /etc/bup-excludes
state: absent
- name: Remove backup cronjob
cron:
name: "Run bup backup"
job: "tar -X /etc/bup-excludes -cPF - / | bup split -r {{ bup_username }}@{{ item }}: -n root -q"
user: root
hour: '5'
minute: '{{ 59|random(seed=item) }}'
state: absent
with_inventory_hostnames: backup-server