mirror of
https://github.com/roles-ansible/ansible_role_restic/
synced 2024-12-11 20:30:18 +01:00
change: backups can be defined as dicts (#28)
* convert * use loop * clean * combine * change: reformat dict * fix * fix2 * update readme
This commit is contained in:
parent
649f6aae0c
commit
790dae3ef4
4 changed files with 41 additions and 4 deletions
11
README.md
11
README.md
|
@ -65,12 +65,12 @@ ansible-galaxy install arillso.restic
|
|||
| Name | Default | Description |
|
||||
| ---------------------- | -------------------- | --------------------------------------------------------------------------- |
|
||||
| `restic_url` | `undefined` | The URL to download restic from. Use this variable to overwrite the default |
|
||||
| `restic_version` | `'0.11.0'` | The version of Restic to install |
|
||||
| `restic_version` | `'0.11.0'` | The version of Restic to install |
|
||||
| `restic_download_path` | `'/opt/restic'` | Download location for the restic binary |
|
||||
| `restic_install_path` | `'/usr/local/bin'` | Install location for the restic binary |
|
||||
| `restic_script_dir` | `'~/restic'` | Location of the generated backup scripts |
|
||||
| `restic_repos` | `{}` | A dictionary of repositories where snapshots are stored |
|
||||
| `restic_backups` | `[]` | A list of dictionaries specifying the files and directories to be backed up |
|
||||
| `restic_backups` | `{}` (or `[]`) | A list of dictionaries specifying the files and directories to be backed up |
|
||||
| `restic_create_cron` | `false` | Should a cronjob be created for each backup |
|
||||
| `restic_dir_owner` | `'{{ansible_user}}'` | The owner of all created dirs |
|
||||
| `restic_dir_group` | `'{{ansible_user}}'` | The group of all created dirs |
|
||||
|
@ -146,13 +146,18 @@ Available variables:
|
|||
Example:
|
||||
```yaml
|
||||
restic_backups:
|
||||
- name: data
|
||||
data:
|
||||
name: data
|
||||
repo: remove
|
||||
src: /path/to/data
|
||||
scheduled: true
|
||||
schedule_hour: 3
|
||||
```
|
||||
|
||||
> You can also specify restic_backups as an array, which is a legacy feature and
|
||||
> might be deprecated in the future. currently, the name key is used for
|
||||
> namint the access and backup files
|
||||
|
||||
#### Exclude
|
||||
the `exclude` key on a backup allows you to specify multiple files to exclude or
|
||||
files to look for filenames to be excluded. You can specify the following keys:
|
||||
|
|
|
@ -32,3 +32,28 @@
|
|||
keep_daily: 7
|
||||
keep_monthly: 12
|
||||
keep_yearly: 5
|
||||
|
||||
- name: Converge with dict
|
||||
hosts: all
|
||||
roles:
|
||||
- role: ansible.restic
|
||||
pre_tasks:
|
||||
- name: install bzip2
|
||||
package:
|
||||
name: bzip2
|
||||
state: present
|
||||
vars:
|
||||
restic_download_path: ~/restic
|
||||
restic_install_path: ~/restic
|
||||
restic_repos:
|
||||
local:
|
||||
location: /backup
|
||||
password: securepassword1
|
||||
init: true
|
||||
restic_backups:
|
||||
dicttest:
|
||||
name: dicttest
|
||||
src: /home
|
||||
repo: local
|
||||
keep_last: 4
|
||||
keep_tag: deployment
|
||||
|
|
|
@ -22,5 +22,6 @@
|
|||
args:
|
||||
chdir: ~/restic/
|
||||
with_items:
|
||||
- backup-dicttest.sh
|
||||
- backup-test.sh
|
||||
- backup-test_stdin.sh
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
---
|
||||
# tasks file for skeleton
|
||||
|
||||
- name: reformat dict if necessary
|
||||
set_fact:
|
||||
restic_backups: "{{ restic_backups|dict2items|json_query('[*].value') }}"
|
||||
when:
|
||||
- restic_backups | type_debug == "dict"
|
||||
|
||||
- name: Create backup credentials
|
||||
template:
|
||||
src: restic_access_Linux.j2
|
||||
|
@ -42,8 +48,8 @@
|
|||
state: present
|
||||
become: true
|
||||
no_log: true
|
||||
with_items: '{{ restic_backups }}'
|
||||
when:
|
||||
- restic_create_cron
|
||||
- item.name is defined
|
||||
- item.scheduled | default(false)
|
||||
with_items: '{{ restic_backups }}'
|
||||
|
|
Loading…
Reference in a new issue