Add borg
This commit is contained in:
parent
31744304a1
commit
18ef613556
7 changed files with 33 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
13
roles/borg/tasks/base.yml
Normal 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
|
8
roles/borg/tasks/cron.yml
Normal file
8
roles/borg/tasks/cron.yml
Normal 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
|
7
roles/borg/tasks/main.yml
Normal file
7
roles/borg/tasks/main.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
|
||||
- ansible.builtin.import_tasks: base.yml
|
||||
name: base
|
||||
|
||||
- ansible.builtin.import_tasks: cron.yml
|
||||
name: cron
|
2
roles/borg/templates/backup.j2
Normal file
2
roles/borg/templates/backup.j2
Normal 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)" .
|
Loading…
Reference in a new issue