Move to backup timers instead of cronjobs, lay groundwork for backing up personal systems

This commit is contained in:
Salt 2020-06-30 06:22:27 -05:00
parent d095148efc
commit 622dcacc07
7 changed files with 55 additions and 7 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/ansible-playbook #!/usr/bin/ansible-playbook
# vim:ft=ansible: # vim:ft=ansible:
backups_hour: "*/6" backups_frequency: 6h
mcheapmax: 4096 mcheapmax: 4096
mcheapmin: 1024 mcheapmin: 1024

View File

@ -1,3 +1,5 @@
#!/usr/bin/ansible-playbook #!/usr/bin/ansible-playbook
# vim:ft=ansible: # vim:ft=ansible:
ansible_pull_frequency: "8h" ansible_pull_frequency: 8h
backups_frequency: 7d
aws_backup_bucket: "9iron-backups-home"

View File

@ -1,4 +1,5 @@
#!/usr/bin/ansible-playbook #!/usr/bin/ansible-playbook
# vim:ft=ansible: # vim:ft=ansible:
backups_outdir: "/opt/backups/out" backups_outdir: "/opt/backups/out"
backups_hour: "2" backups_boot_delay: 1h
backups_frequency: 24h

View 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

View File

@ -22,10 +22,24 @@
src: "backup.sh" src: "backup.sh"
dest: "/opt/backups/backup.sh" dest: "/opt/backups/backup.sh"
mode: "0700" 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: cron:
minute: "0" state: absent
hour: "{{ backups_hour }}"
name: ansible-backup name: ansible-backup
job: "/opt/backups/backup.sh >> /backups/backups.log 2>&1"
become: yes become: yes

View 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

View 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