From e9caa74560ef808441c2a73b3c503347e7b4ba08 Mon Sep 17 00:00:00 2001 From: K Date: Thu, 24 Dec 2020 01:23:33 +0100 Subject: [PATCH] Add options for consistency checks and storage. By @kenayagi (#50) * borg_remote_rate_limit config * borg_remote_rate_limit optional argument * Set default rate_limit to 0 (unlimited) * additional options for checks and storage --- README.md | 5 +++++ defaults/main.yml | 12 ++++++++++-- templates/config.yaml.j2 | 34 ++++++++++++++++++++++------------ 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 471177d..4312d31 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,11 @@ $ git clone https://github.com/borgbase/ansible-role-borgbackup.git roles/borgba ### Optional Arguments - `borg_encryption_passphrase`: Password to use for repokey or keyfile. Empty if repo is unencrypted. +- `borgmatic_checks`: List of consistency checks. Defaults to `['repository']` +- `borgmatic_check_last`: Number of archives to check. Defaults to `3` +- `borgmatic_store_atime`: Store atime into archive. Defaults to `true` +- `borgmatic_store_ctime`: Store ctime into archive. Defaults to `true` +- `borgmatic_relocated_repo_access_is_ok`: Bypass Borg error about a repository that has been moved. Defaults to `false` - `borgmatic_config_name`: Name to use for the borgmatic config file. Defaults to `config.yaml` - `borgmatic_large_repo`: Less frequent, monthly repo checking. Defaults to `true` - `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` diff --git a/defaults/main.yml b/defaults/main.yml index 7a613e1..08b58c6 100755 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -5,8 +5,16 @@ borgmatic_config_name: config.yaml borgmatic_large_repo: true borgmatic_failure_command: - echo "`date` - Error while creating a backup." -borgmatic_before_backup_command: [] -borgmatic_after_backup_command: [] +borgmatic_before_backup_command: + - echo "`date` - Starting backup." +borgmatic_after_backup_command: + - echo "`date` - Finished backup." +borgmatic_checks: + - repository +borgmatic_check_last: 3 +borgmatic_store_atime: true +borgmatic_store_ctime: true +borgmatic_relocated_repo_access_is_ok: false borgmatic_hooks: [] borg_one_file_system: true borg_exclude_from: [] diff --git a/templates/config.yaml.j2 b/templates/config.yaml.j2 index 0d457f4..9ce4216 100644 --- a/templates/config.yaml.j2 +++ b/templates/config.yaml.j2 @@ -1,5 +1,5 @@ #jinja2: lstrip_blocks: "True", trim_blocks: "True" -# Full config: https://gist.github.com/coaxial/46e36d89d7b81887f7275d587fe04c44 +# Full config: https://torsion.org/borgmatic/docs/reference/config.yaml location: source_directories: {% for dir in borg_source_directories %} @@ -17,6 +17,12 @@ location: - {{ borg_repository }} {% endif %} + # Store atime into archive. + atime: {{ borgmatic_store_atime }} + + # Store ctime into archive. + ctime: {{ borgmatic_store_ctime }} + # Any paths matching these patterns are excluded from backups. Globs and tildes # are expanded. See the output of "borg help patterns" for more details. exclude_patterns: @@ -90,6 +96,9 @@ storage: # prefix in the consistency section as well. archive_name_format: '{hostname}-{now}' + # Bypass Borg error about a repository that has been moved. + relocated_repo_access_is_ok: {{ borgmatic_relocated_repo_access_is_ok }} + # Retention policy for how many backups to keep in each category. See # https://borgbackup.readthedocs.org/en/stable/usage.html#borg-prune for details. # At least one of the "keep" options is required for pruning to work. @@ -138,18 +147,21 @@ retention: # https://borgbackup.readthedocs.org/en/stable/usage.html#borg-check and # https://borgbackup.readthedocs.org/en/stable/usage.html#borg-extract for details. consistency: - # List of one or more consistency checks to run: "repository", "archives", and/or - # "extract". Defaults to "repository" and "archives". Set to "disabled" to disable - # all consistency checks. "repository" checks the consistency of the repository, - # "archive" checks all of the archives, and "extract" does an extraction dry-run - # of just the most recent archive. + # List of one or more consistency checks to run: "repository", + # "archives", "data", and/or "extract". Defaults to + # "repository" and "archives". Set to "disabled" to disable + # all consistency checks. "repository" checks the consistency + # of the repository, "archives" checks all of the archives, + # "data" verifies the integrity of the data within the + # archives, and "extract" does an extraction dry-run of the + # most recent archive. Note that "data" implies "archives". checks: - - repository - # - archives - # - disabled + {% for checks in borgmatic_checks %} + - {{ checks }} + {% endfor %} # Restrict the number of checked archives to the last n. Applies only to the "archives" check. - check_last: 3 + check_last: {{ borgmatic_check_last }} # When performing the "archives" check, only consider archive names starting with # this prefix. Borg placeholders can be used. See the output of @@ -163,14 +175,12 @@ consistency: 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 %}