diff --git a/README.md b/README.md index 406c7e6..fafd8d1 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,9 @@ An Ansible Role that sets up automated remote backups on the target machine. Use - `borg_encryption_passphrase`: Password to use for repokey or keyfile. Empty if repo is unencrypted. - `borgmatic_large_repo`: Does repo-checking on a weekly basis instead of daily. Good for repos with 100GB+ size. - `borgmatic_failure_command`: Run this command when an error occurs. E.g. `curl -s -F "token=xxx" -F "user=xxx" -F "message=Error during backup" https://api.pushover.net/1/messages.json` +- `borgmatic_before_backup_command`: Run this command before the backup. E.g. `dump-a-database /to/file.sql` +- `borgmatic_after_backup_command`: Run this command after the backup. E.g. `rm /to/file.sql` +- `borgmatic_failure_command`: Run this command when an error occurs. E.g. `curl -s -F "token=xxx" -F "user=xxx" -F "message=Error during backup" https://api.pushover.net/1/messages.json` - `borg_exclude_patterns`: Paths or patterns to exclude from backup. See [official documentation](https://borgbackup.readthedocs.io/en/stable/usage/help.html#borg-help-patterns) for more. - `borg_one_file_system`: Don't cross file-system boundaries. Defaults to `true` - `borg_exclude_from`: Read exclude patterns from one or more separate named files, one pattern per line. diff --git a/defaults/main.yml b/defaults/main.yml index 8978c2b..b53f512 100755 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -2,7 +2,10 @@ borg_encryption_passphrase: '' borg_exclude_patterns: [] borgmatic_large_repo: false -borgmatic_failure_command: echo "`date` - Error while creating a backup." +borgmatic_failure_command: + - echo "`date` - Error while creating a backup." +borgmatic_before_backup_command: [] +borgmatic_after_backup_command: [] borg_one_file_system: true borg_exclude_from: [] borg_encryption_passcommand: false diff --git a/templates/config.yaml.j2 b/templates/config.yaml.j2 index d2538f5..1e39d72 100644 --- a/templates/config.yaml.j2 +++ b/templates/config.yaml.j2 @@ -147,11 +147,19 @@ hooks: # List of one or more shell commands or scripts to execute before creating a backup. before_backup: - echo "`date` - Starting backup." +{% for cmd in borgmatic_before_backup_command %} + - {{ cmd }} +{% endfor %} # List of one or more shell commands or scripts to execute after creating a backup. after_backup: - echo "`date` - Finished backup." +{% for cmd in borgmatic_after_backup_command %} + - {{ cmd }} +{% endfor %} # List of one or more shell commands or scripts to execute in case an exception has occurred. on_error: - - {{ borgmatic_failure_command }} +{% for cmd in borgmatic_failure_command %} + - {{ cmd }} +{% endfor %}