diff --git a/files/choux_borg.service b/files/choux_borg.service new file mode 100644 index 0000000..2f1ac16 --- /dev/null +++ b/files/choux_borg.service @@ -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 }} diff --git a/files/choux_borg_cron.sh b/files/choux_borg.sh similarity index 100% rename from files/choux_borg_cron.sh rename to files/choux_borg.sh diff --git a/files/choux_borg.timer b/files/choux_borg.timer new file mode 100644 index 0000000..9a3b3e4 --- /dev/null +++ b/files/choux_borg.timer @@ -0,0 +1,11 @@ +[Unit] +Description=Borg Backup Timer + +[Timer] +WakeSystem=false +OnCalendar=daily +Persistent=true +RandomizedDelaySec=10min + +[Install] +WantedBy=timers.target diff --git a/tasks/choux_borg_backup.yml b/tasks/choux_borg_backup.yml index 39cb8b5..548345f 100644 --- a/tasks/choux_borg_backup.yml +++ b/tasks/choux_borg_backup.yml @@ -4,14 +4,26 @@ name: borg state: present -- name: Automate toward local RAID backup with cron.daily +- name: Automate toward local RAID backup with systemd timer template: - src: files/choux_borg_cron.sh - dest: /etc/cron.daily/ + src: files/choux_borg.sh + dest: {{ borg_script_path }} 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: - name: cronie + name: choux_borg state: started enabled: yes diff --git a/vars/Choux.yml b/vars/Choux.yml index 74a5807..f545ea4 100644 --- a/vars/Choux.yml +++ b/vars/Choux.yml @@ -3,5 +3,6 @@ deploy_public_key: files/id_ed25519_home.pub borg_backup_repo: /media/backup/Choux +borg_script_path: /root/.borg/backup.sh