File tree Expand file tree Collapse file tree 9 files changed +36
-14
lines changed
Expand file tree Collapse file tree 9 files changed +36
-14
lines changed Original file line number Diff line number Diff line change @@ -56,11 +56,14 @@ CRON=true /path/to/backup/script/backup-example.sh
5656```
5757## Installation
5858
59+ There are multiple ways to install the role. Either clone or download it directly from the [ github repository] ( https://github.com/roles-ansible/ansible_role_restic.git ) . Or Install it via [ ansible galaxy] ( https://galaxy.ansible.com/do1jlr/restic ) :
5960``` bash
60- ansible-galaxy install arillso .restic
61+ ansible-galaxy install do1jlr .restic
6162```
6263## Requirements
6364* bzip2
65+ * jmespath
66+
6467## Role Variables
6568
6669| Name | Default | Description |
@@ -81,6 +84,7 @@ ansible-galaxy install arillso.restic
8184| ` restic_do_not_cleanup_cron ` | ` false ` | we changed the cron location and clean up the old one. You can skip the cleanup here |
8285| ` restic__cache_config ` | ` false ` | configure custom cache directory |
8386| ` restic__cache_dir ` | ` '~/.cache/restic' ` | define custom cache directory |
87+ | ` submodules_versioncheck ` | ` false ` | if you set this variable to true, the role will run a [ simple versionscheck] ( tasks/versioncheck.yml ) to prevent running older versions of this role. |
8488
8589### Repos
8690Restic stores data in repositories. You have to specify at least one repository
@@ -192,13 +196,29 @@ Please refer to the use of the specific keys to the
192196[documentation](https://restic.readthedocs.io/en/latest/040_backup.html#excluding-files).
193197
194198# # Dependencies
195- none
199+ This role does not have any other ansible role as dependencie.
200+
196201# # Example Playbook
197202
198203` ` ` yml
199- - hosts: all
204+ - name: backup your homefolders to /mnt/backup everyday night
205+ hosts: localhost
200206 roles:
201- - restic
207+ - {role: do1jlr.restic, tags: restic}
208+ vars:
209+ restic_create_schedule: true
210+ restic_repos:
211+ local:
212+ location: '/mnt/backup'
213+ password: 'ChangM3'
214+ init: true
215+ restic_backups:
216+ home:
217+ name: home
218+ repo: local
219+ src: /home/
220+ scheduled: true
221+ schedule_oncalendar: '*-*-* 01:00:00'
202222` ` `
203223
204224# # License
Original file line number Diff line number Diff line change 11---
2- # defaults file for skeleton
32restic_url : ' {{ restic_url_default }}'
43restic_version : ' 0.12.1'
54restic_download_path : ' /opt/restic'
@@ -18,7 +17,7 @@ restic_dir_group: '{{ ansible_user | default(ansible_user_id) }}'
1817
1918# timer defaults
2019restic_systemd_timer_randomizeddelaysec : ' 4h'
21- restic_systemd_timer_default_OnCalendar : ' *-*-* 02:00:00'
20+ restic_systemd_timer_default_oncalendar : ' *-*-* 02:00:00'
2221
2322# perform simple version check for this role? (true is recomended)
2423submodules_versioncheck : false
Original file line number Diff line number Diff line change 11---
22- name : (BACKUP) reformat dict if necessary
3- set_fact :
3+ ansible.builtin. set_fact :
44 restic_backups : " {{ restic_backups|dict2items|json_query('[*].value') }}"
55 when :
66 - restic_backups | type_debug == "dict"
77
88- name : (BACKUP) Create backup credentials
9- template :
9+ ansible.builtin. template :
1010 src : restic_access_Linux.j2
1111 dest : " {{ restic_script_dir }}/access-{{ item.name | replace(' ', '') }}.sh"
1212 mode : ' 0700'
2121 - item.repo in restic_repos
2222
2323- name : (BACKUP) Create backup script
24- template :
24+ ansible.builtin. template :
2525 src : restic_script_Linux.j2
2626 dest : " {{ restic_script_dir }}/backup-{{ item.name | replace(' ', '') }}.sh"
2727 mode : ' 0700'
Original file line number Diff line number Diff line change 11---
22- name : (CONF)Initialize repository
3- command : ' {{ restic_install_path }}/restic init'
3+ ansible.builtin. command : ' {{ restic_install_path }}/restic init'
44 environment :
55 RESTIC_REPOSITORY : ' {{ item.value.location }}'
66 RESTIC_PASSWORD : ' {{ item.value.password }}'
Original file line number Diff line number Diff line change 22# tasks file for skeleton
33
44- name : Message
5- debug :
5+ ansible.builtin. debug :
66 msg : ' Your {{ ansible_system }} is not supported'
Original file line number Diff line number Diff line change 77 url : ' {{ restic_url }}'
88 dest : ' {{ restic_download_path }}/restic.bz2'
99 force : true
10+ mode : 0644
1011 register : get_url_restic
1112
1213 # TODO: This needs to become independent of the shell module to actually work
2627 ansible.builtin.command : " {{ restic_bin_bath }} version"
2728 ignore_errors : true
2829 register : restic_test_result
30+ changed_when : false
2931
3032 - name : (INSTALL) Remove faulty binary
3133 ansible.builtin.file :
5052 - name : (INSTALL) try restic self-update
5153 become : true
5254 ansible.builtin.command : " {{ restic_install_path }}/restic self-update"
55+ changed_when : true
Original file line number Diff line number Diff line change 6262 - restic_create_schedule | bool
6363 rescue :
6464 - name : set cronjob intead of systemd
65- set_fact :
65+ ansible.builtin. set_fact :
6666 restic_force_cron : true
Original file line number Diff line number Diff line change 22Description=Run restic backup {{ item.name }} every night
33
44[Timer]
5- OnCalendar={{ item.schedule_oncalendar | default(restic_systemd_timer_default_OnCalendar ) }}
5+ OnCalendar={{ item.schedule_oncalendar | default(restic_systemd_timer_default_oncalendar ) }}
66RandomizedDelaySec={{ restic_systemd_timer_randomizeddelaysec }}
77Persistent=true
88
Original file line number Diff line number Diff line change @@ -10,5 +10,5 @@ restic_os_variables:
1010 paths :
1111 - ' vars'
1212
13- playbook_version_number : 24 # should be int
13+ playbook_version_number : 25 # should be int
1414playbook_version_path : ' do1jlr.restic.version'
You can’t perform that action at this time.
0 commit comments