Allow flexible name for Borgmatic config file. (#1)

This commit is contained in:
Manu 2018-10-29 11:27:25 +08:00
parent 0aad2dde68
commit 667897daad
3 changed files with 15 additions and 7 deletions

View File

@ -5,9 +5,10 @@ An Ansible Role that installs that sets up BorgBackup on Debian/Ubuntu.
## Role Variables ## Role Variables
- `borg_repository` (required): Full path to repository. Your own server or [BorgBase.com](https://www.borgbase.com) repo. - `borg_repository` (required): Full path to repository. Your own server or [BorgBase.com](https://www.borgbase.com) repo.
- `borg_encryption_passphrase` (optional): Password to use for repokey or keyfile. Empty if repo is unencrypted.
- `borg_source_directories` (required): List of local folders to back up. - `borg_source_directories` (required): List of local folders to back up.
- `borg_exclude_patterns` (optional): List of local folders to exclude. - `borg_encryption_passphrase` (optional): Password to use for repokey or keyfile. Empty if repo is unencrypted.
- `borgmatic_config_name` (optional): Name to use for the borgmatic config file. Defaults to `config.yml`
- `borg_exclude_patterns` (optional): Paths or patterns to exclude from backup. See [official documentation](https://borgbackup.readthedocs.io/en/stable/usage/help.html#borg-help-patterns) for more.
## Example Playbook ## Example Playbook
@ -22,9 +23,14 @@ An Ansible Role that installs that sets up BorgBackup on Debian/Ubuntu.
- /srv/www - /srv/www
- /var/lib/automysqlbackup - /var/lib/automysqlbackup
borg_exclude_patterns: borg_exclude_patterns:
- /srv/www/upload - /srv/www/old-sites
``` ```
## Planned features
- [ ] Testing via vagrant
- [ ] Multiple repos in one role-call instead of callng this role multiple times.
## License ## License
MIT/BSD MIT/BSD

View File

@ -1,3 +1,4 @@
--- ---
borg_encryption_passphrase: '' borg_encryption_passphrase: ''
borg_exclude_patterns: [] borg_exclude_patterns: []
borgmatic_config_name: config.yaml

View File

@ -35,7 +35,7 @@
- name: Add Borgmatic Configuration - name: Add Borgmatic Configuration
template: template:
src: config.yaml.j2 src: config.yaml.j2
dest: "/etc/borgmatic/config.yaml" dest: "/etc/borgmatic/{{ borgmatic_config_name }}"
mode: 0600 mode: 0600
- name: Add cron-job for borgmatic - name: Add cron-job for borgmatic
@ -45,7 +45,7 @@
minute: "{{ 59 |random }}" minute: "{{ 59 |random }}"
user: "root" user: "root"
cron_file: borgmatic cron_file: borgmatic
job: "/usr/local/bin/borgmatic" job: "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}"
- name: Set PATH for borgmatic cron job. - name: Set PATH for borgmatic cron job.
cron: cron:
@ -53,4 +53,5 @@
cron_file: borgmatic cron_file: borgmatic
name: PATH name: PATH
env: yes env: yes
value: /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin value: /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
4