Fix(Choux): borg backup from cron to systemd timer

This commit is contained in:
Bertrand Benjamin 2018-10-08 10:28:02 +02:00
parent 443db2c375
commit 47ef169667
5 changed files with 39 additions and 5 deletions

10
files/choux_borg.service Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Description=Borg Backup
[Service]
Type=simple
Nice=19
IOSchedulingClass=2
IOSchedulingPriority=7
ExecStartPre=/usr/bin/borg break-lock {{ borg_backup_repo }}
ExecStart={{ borg_script_path }}

11
files/choux_borg.timer Normal file
View File

@ -0,0 +1,11 @@
[Unit]
Description=Borg Backup Timer
[Timer]
WakeSystem=false
OnCalendar=daily
Persistent=true
RandomizedDelaySec=10min
[Install]
WantedBy=timers.target

View File

@ -4,14 +4,26 @@
name: borg name: borg
state: present state: present
- name: Automate toward local RAID backup with cron.daily - name: Automate toward local RAID backup with systemd timer
template: template:
src: files/choux_borg_cron.sh src: files/choux_borg.sh
dest: /etc/cron.daily/ dest: {{ borg_script_path }}
mode: 755 mode: 755
- name: Enable cronie daemon - name: Backup systemd timer
template:
src: files/choux_borg.timer
dest: /etc/systemd/system/
mode: 755
- name: Backup systemd service
template:
src: files/choux_borg.service
dest: /etc/systemd/system/
mode: 755
- name: Enable systemd borg script
service: service:
name: cronie name: choux_borg
state: started state: started
enabled: yes enabled: yes

View File

@ -3,5 +3,6 @@
deploy_public_key: files/id_ed25519_home.pub deploy_public_key: files/id_ed25519_home.pub
borg_backup_repo: /media/backup/Choux borg_backup_repo: /media/backup/Choux
borg_script_path: /root/.borg/backup.sh