Compare commits
1 Commits
768aecc9a4
...
4a7cd07ac9
Author | SHA1 | Date | |
---|---|---|---|
4a7cd07ac9 |
@ -11,5 +11,16 @@ restic_bin_path: /usr/local/bin
|
||||
restic_etc_path: /etc/restic
|
||||
restic_path: "{{ restic_bin_path }}/restic"
|
||||
|
||||
restic_global_exclude:
|
||||
- /dev
|
||||
- /media
|
||||
- /mnt
|
||||
- /proc
|
||||
- /run
|
||||
- /sys
|
||||
- /tmp
|
||||
- /var/tmp
|
||||
- /var/lib/lxcfs/cgroup
|
||||
|
||||
restic_repos: []
|
||||
restic_jobs: []
|
||||
|
@ -7,6 +7,14 @@
|
||||
mode: 0755
|
||||
state: directory
|
||||
|
||||
- name: create repo environment helper
|
||||
template:
|
||||
src: job-env.sh.j2
|
||||
dest: "{{ restic_etc_path }}/jobs/{{ item.name }}/env.sh"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0400
|
||||
|
||||
- name: create job exclude file
|
||||
template:
|
||||
src: exclude.txt.j2
|
||||
@ -19,10 +27,10 @@
|
||||
cron:
|
||||
name: "restic {{ item.name }} job"
|
||||
hour: "{{ item.cron.hour | default(omit) }}"
|
||||
minute: "{{ item.cron.minute | default(omit) }}"
|
||||
minute: "{{ item.cron.minute | default(60 | random(seed=inventory_hostname)) }}"
|
||||
day: "{{ item.cron.day | default(omit) }}"
|
||||
month: "{{ item.cron.month | default(omit) }}"
|
||||
weekday: "{{ item.cron.weekday | default(omit) }}"
|
||||
user: "{{ item.cron.user | default('root') }}"
|
||||
state: "{{ item.cron.state | default('present') }}"
|
||||
job: ". {{ restic_etc_path }}/repos/{{ item.repo }}/env.sh && restic backup -q --exclude-file {{ restic_etc_path }}/jobs/{{ item.name }}/exclude.txt {{ item.paths | join(' ') }}"
|
||||
job: "{{ restic_bin_path }}/restic-job {{ item.name }}"
|
||||
|
@ -65,6 +65,22 @@
|
||||
- "{{ restic_etc_path }}/repos"
|
||||
- "{{ restic_etc_path }}/jobs"
|
||||
|
||||
- name: create restic job wrapper script
|
||||
template:
|
||||
src: restic-job.sh.j2
|
||||
dest: "{{ restic_bin_path }}/restic-job"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
|
||||
- name: create restic tidy wrapper
|
||||
template:
|
||||
src: restic-tidy.sh.j2
|
||||
dest: "{{ restic_bin_path }}/restic-tidy"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
|
||||
- name: manage repos
|
||||
include: repo.yaml
|
||||
loop: "{{ restic_repos | default([]) }}"
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
- name: get repo status
|
||||
shell:
|
||||
cmd: restic -q -r {{ item.repo }} snapshots 2> /dev/null
|
||||
cmd: restic -q -r {{ item.repo }} --no-lock snapshots 2> /dev/null
|
||||
ignore_errors: yes
|
||||
environment: "{{ item.environment | default({}) }}"
|
||||
register: restic_init
|
||||
@ -30,8 +30,17 @@
|
||||
|
||||
- name: create repo environment helper
|
||||
template:
|
||||
src: env.sh.j2
|
||||
src: repo-env.sh.j2
|
||||
dest: "{{ restic_etc_path }}/repos/{{ item.name }}/env.sh"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0400
|
||||
|
||||
- name: create cron
|
||||
cron:
|
||||
name: "restic {{ item.name }} tidy"
|
||||
hour: "0"
|
||||
minute: "{{ 60 | random(seed=inventory_hostname) }}"
|
||||
user: root
|
||||
state: present
|
||||
job: "{{ restic_bin_path }}/restic-tidy {{ item.name }}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user