1
0
Fork 0
This commit is contained in:
Florian RICHER 2023-06-09 02:23:19 +02:00
parent 31744304a1
commit 18ef613556
7 changed files with 33 additions and 0 deletions

View file

@ -4,6 +4,7 @@ server:
domain: mrdev023.fr
ssh_port: 7943
work_dir: /mnt/work
backup_dir: /mnt/backup
acme:
email: florian.richer.97@outlook.com
debug: true

View file

@ -4,6 +4,7 @@ server:
domain: mrdev023.test
ssh_port: 22
work_dir: /mnt/test
backup_dir: /mnt/btest
acme:
email: test@test.fr
debug: true

View file

@ -13,4 +13,5 @@
- { role: n8n, tags: ["n8n"] }
- { role: matrix, tags: ["matrix"] }
- { role: iptables, tags: ["iptables"] }
- { role: borg, tags: ["borg"] }
- { role: clean, tags: ["clean"] }

13
roles/borg/tasks/base.yml Normal file
View file

@ -0,0 +1,13 @@
---
- name: Copy template conf
ansible.builtin.template:
backup: true
src: "{{ item.src }}"
dest: "/usr/bin/{{ item.dest }}"
group: root
owner: root
mode: u=rwx,g=rx,o=rx
loop:
- { src: 'backup.j2', dest: 'backup' }
become: true

View file

@ -0,0 +1,8 @@
---
- name: Ensure a job that run to backup data
ansible.builtin.cron:
name: "borg backup"
special_time: "daily"
job: "/usr/bin/backup"
become: yes

View file

@ -0,0 +1,7 @@
---
- ansible.builtin.import_tasks: base.yml
name: base
- ansible.builtin.import_tasks: cron.yml
name: cron

View file

@ -0,0 +1,2 @@
#!/bin/sh
cd {{ server.work_dir }} && borg create --stats -C zstd,22 --progress "{{ server.backup_dir }}::$(date --iso-8601=seconds)" .