From 667897daadb36a8523604a02fccb77f4fc1bee6f Mon Sep 17 00:00:00 2001 From: Manu Date: Mon, 29 Oct 2018 11:27:25 +0800 Subject: [PATCH] Allow flexible name for Borgmatic config file. (#1) --- README.md | 12 +++++++++--- defaults/main.yml | 3 ++- tasks/main.yml | 7 ++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1253fbe..dbda648 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,10 @@ An Ansible Role that installs that sets up BorgBackup on Debian/Ubuntu. ## Role Variables - `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_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 @@ -22,9 +23,14 @@ An Ansible Role that installs that sets up BorgBackup on Debian/Ubuntu. - /srv/www - /var/lib/automysqlbackup 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 MIT/BSD diff --git a/defaults/main.yml b/defaults/main.yml index 42b2900..da06b4e 100755 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,3 +1,4 @@ --- borg_encryption_passphrase: '' -borg_exclude_patterns: [] \ No newline at end of file +borg_exclude_patterns: [] +borgmatic_config_name: config.yaml \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index abc8962..b5c6bd3 100755 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -35,7 +35,7 @@ - name: Add Borgmatic Configuration template: src: config.yaml.j2 - dest: "/etc/borgmatic/config.yaml" + dest: "/etc/borgmatic/{{ borgmatic_config_name }}" mode: 0600 - name: Add cron-job for borgmatic @@ -45,7 +45,7 @@ minute: "{{ 59 |random }}" user: "root" 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. cron: @@ -53,4 +53,5 @@ cron_file: borgmatic name: PATH env: yes - value: /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin \ No newline at end of file + value: /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +4 \ No newline at end of file