mirror of
https://github.com/roles-ansible/ansible_role_restic/
synced 2024-11-14 23:50:19 +01:00
commit
1e0d0b9c92
9 changed files with 36 additions and 14 deletions
28
README.md
28
README.md
|
@ -56,11 +56,14 @@ CRON=true /path/to/backup/script/backup-example.sh
|
||||||
```
|
```
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
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):
|
||||||
```bash
|
```bash
|
||||||
ansible-galaxy install arillso.restic
|
ansible-galaxy install do1jlr.restic
|
||||||
```
|
```
|
||||||
## Requirements
|
## Requirements
|
||||||
* bzip2
|
* bzip2
|
||||||
|
* jmespath
|
||||||
|
|
||||||
## Role Variables
|
## Role Variables
|
||||||
|
|
||||||
| Name | Default | Description |
|
| Name | Default | Description |
|
||||||
|
@ -81,6 +84,7 @@ ansible-galaxy install arillso.restic
|
||||||
| `restic_do_not_cleanup_cron ` | `false` | we changed the cron location and clean up the old one. You can skip the cleanup here |
|
| `restic_do_not_cleanup_cron ` | `false` | we changed the cron location and clean up the old one. You can skip the cleanup here |
|
||||||
| `restic__cache_config` | `false` | configure custom cache directory |
|
| `restic__cache_config` | `false` | configure custom cache directory |
|
||||||
| `restic__cache_dir` | `'~/.cache/restic'` | define custom cache directory |
|
| `restic__cache_dir` | `'~/.cache/restic'` | define custom cache directory |
|
||||||
|
|`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. |
|
||||||
|
|
||||||
### Repos
|
### Repos
|
||||||
Restic stores data in repositories. You have to specify at least one repository
|
Restic 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
|
||||||
[documentation](https://restic.readthedocs.io/en/latest/040_backup.html#excluding-files).
|
[documentation](https://restic.readthedocs.io/en/latest/040_backup.html#excluding-files).
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
none
|
This role does not have any other ansible role as dependencie.
|
||||||
|
|
||||||
## Example Playbook
|
## Example Playbook
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
- hosts: all
|
- name: backup your homefolders to /mnt/backup everyday night
|
||||||
|
hosts: localhost
|
||||||
roles:
|
roles:
|
||||||
- restic
|
- {role: do1jlr.restic, tags: restic}
|
||||||
|
vars:
|
||||||
|
restic_create_schedule: true
|
||||||
|
restic_repos:
|
||||||
|
local:
|
||||||
|
location: '/mnt/backup'
|
||||||
|
password: 'ChangM3'
|
||||||
|
init: true
|
||||||
|
restic_backups:
|
||||||
|
home:
|
||||||
|
name: home
|
||||||
|
repo: local
|
||||||
|
src: /home/
|
||||||
|
scheduled: true
|
||||||
|
schedule_oncalendar: '*-*-* 01:00:00'
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
---
|
---
|
||||||
# defaults file for skeleton
|
|
||||||
restic_url: '{{ restic_url_default }}'
|
restic_url: '{{ restic_url_default }}'
|
||||||
restic_version: '0.12.1'
|
restic_version: '0.12.1'
|
||||||
restic_download_path: '/opt/restic'
|
restic_download_path: '/opt/restic'
|
||||||
|
@ -18,7 +17,7 @@ restic_dir_group: '{{ ansible_user | default(ansible_user_id) }}'
|
||||||
|
|
||||||
# timer defaults
|
# timer defaults
|
||||||
restic_systemd_timer_randomizeddelaysec: '4h'
|
restic_systemd_timer_randomizeddelaysec: '4h'
|
||||||
restic_systemd_timer_default_OnCalendar: '*-*-* 02:00:00'
|
restic_systemd_timer_default_oncalendar: '*-*-* 02:00:00'
|
||||||
|
|
||||||
# perform simple version check for this role? (true is recomended)
|
# perform simple version check for this role? (true is recomended)
|
||||||
submodules_versioncheck: false
|
submodules_versioncheck: false
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
---
|
---
|
||||||
- name: (BACKUP) reformat dict if necessary
|
- name: (BACKUP) reformat dict if necessary
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
restic_backups: "{{ restic_backups|dict2items|json_query('[*].value') }}"
|
restic_backups: "{{ restic_backups|dict2items|json_query('[*].value') }}"
|
||||||
when:
|
when:
|
||||||
- restic_backups | type_debug == "dict"
|
- restic_backups | type_debug == "dict"
|
||||||
|
|
||||||
- name: (BACKUP) Create backup credentials
|
- name: (BACKUP) Create backup credentials
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: restic_access_Linux.j2
|
src: restic_access_Linux.j2
|
||||||
dest: "{{ restic_script_dir }}/access-{{ item.name | replace(' ', '') }}.sh"
|
dest: "{{ restic_script_dir }}/access-{{ item.name | replace(' ', '') }}.sh"
|
||||||
mode: '0700'
|
mode: '0700'
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
- item.repo in restic_repos
|
- item.repo in restic_repos
|
||||||
|
|
||||||
- name: (BACKUP) Create backup script
|
- name: (BACKUP) Create backup script
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: restic_script_Linux.j2
|
src: restic_script_Linux.j2
|
||||||
dest: "{{ restic_script_dir }}/backup-{{ item.name | replace(' ', '') }}.sh"
|
dest: "{{ restic_script_dir }}/backup-{{ item.name | replace(' ', '') }}.sh"
|
||||||
mode: '0700'
|
mode: '0700'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
- name: (CONF)Initialize repository
|
- name: (CONF)Initialize repository
|
||||||
command: '{{ restic_install_path }}/restic init'
|
ansible.builtin.command: '{{ restic_install_path }}/restic init'
|
||||||
environment:
|
environment:
|
||||||
RESTIC_REPOSITORY: '{{ item.value.location }}'
|
RESTIC_REPOSITORY: '{{ item.value.location }}'
|
||||||
RESTIC_PASSWORD: '{{ item.value.password }}'
|
RESTIC_PASSWORD: '{{ item.value.password }}'
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
# tasks file for skeleton
|
# tasks file for skeleton
|
||||||
|
|
||||||
- name: Message
|
- name: Message
|
||||||
debug:
|
ansible.builtin.debug:
|
||||||
msg: 'Your {{ ansible_system }} is not supported'
|
msg: 'Your {{ ansible_system }} is not supported'
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
url: '{{ restic_url }}'
|
url: '{{ restic_url }}'
|
||||||
dest: '{{ restic_download_path }}/restic.bz2'
|
dest: '{{ restic_download_path }}/restic.bz2'
|
||||||
force: true
|
force: true
|
||||||
|
mode: 0644
|
||||||
register: get_url_restic
|
register: get_url_restic
|
||||||
|
|
||||||
# TODO: This needs to become independent of the shell module to actually work
|
# TODO: This needs to become independent of the shell module to actually work
|
||||||
|
@ -26,6 +27,7 @@
|
||||||
ansible.builtin.command: "{{ restic_bin_bath }} version"
|
ansible.builtin.command: "{{ restic_bin_bath }} version"
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: restic_test_result
|
register: restic_test_result
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
- name: (INSTALL) Remove faulty binary
|
- name: (INSTALL) Remove faulty binary
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
|
@ -50,3 +52,4 @@
|
||||||
- name: (INSTALL) try restic self-update
|
- name: (INSTALL) try restic self-update
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.command: "{{ restic_install_path }}/restic self-update"
|
ansible.builtin.command: "{{ restic_install_path }}/restic self-update"
|
||||||
|
changed_when: true
|
||||||
|
|
|
@ -62,5 +62,5 @@
|
||||||
- restic_create_schedule | bool
|
- restic_create_schedule | bool
|
||||||
rescue:
|
rescue:
|
||||||
- name: set cronjob intead of systemd
|
- name: set cronjob intead of systemd
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
restic_force_cron: true
|
restic_force_cron: true
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Description=Run restic backup {{ item.name }} every night
|
Description=Run restic backup {{ item.name }} every night
|
||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnCalendar={{ item.schedule_oncalendar | default(restic_systemd_timer_default_OnCalendar) }}
|
OnCalendar={{ item.schedule_oncalendar | default(restic_systemd_timer_default_oncalendar) }}
|
||||||
RandomizedDelaySec={{ restic_systemd_timer_randomizeddelaysec }}
|
RandomizedDelaySec={{ restic_systemd_timer_randomizeddelaysec }}
|
||||||
Persistent=true
|
Persistent=true
|
||||||
|
|
||||||
|
|
|
@ -10,5 +10,5 @@ restic_os_variables:
|
||||||
paths:
|
paths:
|
||||||
- 'vars'
|
- 'vars'
|
||||||
|
|
||||||
playbook_version_number: 24 # should be int
|
playbook_version_number: 25 # should be int
|
||||||
playbook_version_path: 'do1jlr.restic.version'
|
playbook_version_path: 'do1jlr.restic.version'
|
||||||
|
|
Loading…
Reference in a new issue