Move to backup timers instead of cronjobs, lay groundwork for backing up personal systems
This commit is contained in:
parent
d095148efc
commit
622dcacc07
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/ansible-playbook
|
||||
# vim:ft=ansible:
|
||||
backups_hour: "*/6"
|
||||
backups_frequency: 6h
|
||||
mcheapmax: 4096
|
||||
mcheapmin: 1024
|
||||
|
@ -1,3 +1,5 @@
|
||||
#!/usr/bin/ansible-playbook
|
||||
# vim:ft=ansible:
|
||||
ansible_pull_frequency: "8h"
|
||||
ansible_pull_frequency: 8h
|
||||
backups_frequency: 7d
|
||||
aws_backup_bucket: "9iron-backups-home"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/ansible-playbook
|
||||
# vim:ft=ansible:
|
||||
backups_outdir: "/opt/backups/out"
|
||||
backups_hour: "2"
|
||||
backups_boot_delay: 1h
|
||||
backups_frequency: 24h
|
||||
|
10
roles/backups/handlers/main.yml
Normal file
10
roles/backups/handlers/main.yml
Normal file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/ansible-playbook
|
||||
# vim:ft=ansible:
|
||||
---
|
||||
- name: restart backups timer
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
name: 9iron-backup.timer
|
||||
enabled: yes
|
||||
state: restarted
|
||||
become: yes
|
@ -22,10 +22,24 @@
|
||||
src: "backup.sh"
|
||||
dest: "/opt/backups/backup.sh"
|
||||
mode: "0700"
|
||||
- name: Set backup cronjob
|
||||
- name: Template out services
|
||||
template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: "{{ item.mode }}"
|
||||
loop:
|
||||
- { src: "9iron-backup.service", dest: "/etc/systemd/system/9iron-backup.service", mode: "0644" }
|
||||
- { src: "9iron-backup.timer", dest: "/etc/systemd/system/9iron-backup.timer", mode: "0644" }
|
||||
notify: restart backups timer
|
||||
- name: Enable timer
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
name: 9iron-backup.timer
|
||||
enabled: yes
|
||||
state: started
|
||||
notify: restart backups timer
|
||||
- name: Remove legacy cronjob
|
||||
cron:
|
||||
minute: "0"
|
||||
hour: "{{ backups_hour }}"
|
||||
state: absent
|
||||
name: ansible-backup
|
||||
job: "/opt/backups/backup.sh >> /backups/backups.log 2>&1"
|
||||
become: yes
|
||||
|
10
roles/backups/templates/9iron-backup.service
Normal file
10
roles/backups/templates/9iron-backup.service
Normal file
@ -0,0 +1,10 @@
|
||||
# vim:ft=dosini:
|
||||
[Unit]
|
||||
Description=9iron backup service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/opt/backpus/backup.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
11
roles/backups/templates/9iron-backup.timer
Normal file
11
roles/backups/templates/9iron-backup.timer
Normal file
@ -0,0 +1,11 @@
|
||||
# vim:ft=dosini:
|
||||
[Unit]
|
||||
Description=9iron backup timer
|
||||
|
||||
[Timer]
|
||||
Persistent=true
|
||||
OnBootSec={{ backups_boot_delay }}
|
||||
OnUnitActiveSec={{ backups_frequency }}
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
Loading…
Reference in New Issue
Block a user