97 lines
2 KiB
YAML
97 lines
2 KiB
YAML
|
- name: install restic-packages
|
||
|
become: yes
|
||
|
apt:
|
||
|
name:
|
||
|
- restic
|
||
|
- logrotate
|
||
|
state: present
|
||
|
|
||
|
- name: create /etc/restic
|
||
|
become: yes
|
||
|
file:
|
||
|
path: /etc/restic
|
||
|
state: directory
|
||
|
|
||
|
- name: create restic mount-directory
|
||
|
become: yes
|
||
|
file:
|
||
|
path: "{{ restic_mount }}"
|
||
|
state: directory
|
||
|
owner: root
|
||
|
group: root
|
||
|
mode: 0777
|
||
|
|
||
|
- name: copy smb_password.txt
|
||
|
become: yes
|
||
|
template:
|
||
|
src: "smb_password.txt"
|
||
|
dest: "/etc/restic/smb_password.txt"
|
||
|
owner: root
|
||
|
group: root
|
||
|
mode: 0700
|
||
|
|
||
|
- name: copy restic_backup.sh
|
||
|
become: yes
|
||
|
template:
|
||
|
src: "restic_backup.sh"
|
||
|
dest: "/usr/local/bin/restic_backup.sh"
|
||
|
mode: a+x
|
||
|
|
||
|
- name: copy exclude.txt
|
||
|
become: yes
|
||
|
template:
|
||
|
src: "exclude.txt"
|
||
|
dest: "/etc/restic/exclude.txt"
|
||
|
|
||
|
- name: copy password.txt
|
||
|
become: yes
|
||
|
template:
|
||
|
src: "password.txt"
|
||
|
dest: "/etc/restic/password.txt"
|
||
|
owner: root
|
||
|
group: root
|
||
|
mode: 0700
|
||
|
|
||
|
- name: create restic cronjob
|
||
|
become: yes
|
||
|
cron:
|
||
|
name: restic
|
||
|
state: present
|
||
|
job: "/usr/local/bin/restic_backup.sh"
|
||
|
minute: "{{ 59|random(seed=inventory_hostname) }}"
|
||
|
hour: "{{ restic_cron_hours }}"
|
||
|
# siehe: https://stackoverflow.com/questions/33379378/idempotence-and-random-variables-in-ansible
|
||
|
|
||
|
- name: Create restic log
|
||
|
become: true
|
||
|
file:
|
||
|
path: /var/log/restic.log
|
||
|
state: touch
|
||
|
owner: root
|
||
|
group: root
|
||
|
mode: 0644
|
||
|
access_time: preserve
|
||
|
modification_time: preserve
|
||
|
|
||
|
- name: Add restic Log to be Rotated
|
||
|
become: true
|
||
|
blockinfile:
|
||
|
path: /etc/logrotate.d/restic
|
||
|
state: present
|
||
|
create: yes
|
||
|
owner: root
|
||
|
group: root
|
||
|
mode: 0644
|
||
|
block: |
|
||
|
/var/log/restic.log {
|
||
|
su root root
|
||
|
create 0640 root root
|
||
|
rotate 4
|
||
|
weekly
|
||
|
compress
|
||
|
missingok
|
||
|
notifempty
|
||
|
dateext
|
||
|
dateyesterday
|
||
|
}
|