Add option to check large repos only on Sunday.

This commit is contained in:
Manu 2019-05-01 10:39:07 +08:00
parent 2d1c5c5300
commit 6787e98f08
4 changed files with 29 additions and 6 deletions

View File

@ -8,6 +8,7 @@ An Ansible Role that sets up automated remote backups on the target machine. Use
- `borg_source_directories` (required): List of local folders to back up. - `borg_source_directories` (required): List of local folders to back up.
- `borg_encryption_passphrase` (optional): Password to use for repokey or keyfile. Empty if repo is unencrypted. - `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` - `borgmatic_config_name` (optional): Name to use for the borgmatic config file. Defaults to `config.yml`
- `borgmatic_large_repo` (optional): Does repo-checking on a weekly basis instead of daily. Good for repos with 100GB+ size.
- `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. - `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.
- `borg_one_file_system` (optional): Don't cross file-system boundaries. Defaults to `true` - `borg_one_file_system` (optional): Don't cross file-system boundaries. Defaults to `true`
- `borg_exclude_from` (optional): Read exclude patterns from one or more separate named files, one pattern per line. - `borg_exclude_from` (optional): Read exclude patterns from one or more separate named files, one pattern per line.

View File

@ -2,6 +2,7 @@
borg_encryption_passphrase: '' borg_encryption_passphrase: ''
borg_exclude_patterns: [] borg_exclude_patterns: []
borgmatic_config_name: config.yaml borgmatic_config_name: config.yaml
borgmatic_large_repo: false
borg_one_file_system: true borg_one_file_system: true
borg_exclude_from: [] borg_exclude_from: []
borg_encryption_passcommand: false borg_encryption_passcommand: false

View File

@ -46,14 +46,36 @@
dest: "/etc/borgmatic/{{ borgmatic_config_name }}" dest: "/etc/borgmatic/{{ borgmatic_config_name }}"
mode: 0600 mode: 0600
- name: Add cron-job for borgmatic - name: Add cron-job for borgmatic (large repo, create and prune)
cron: cron:
name: "borgmatic" name: "borgmatic-create"
hour: "{{ 4 |random }}" hour: "{{ 6 |random }}"
minute: "{{ 59 |random }}"
user: "root"
cron_file: borgmatic
job: "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }} --create --prune"
when: borgmatic_large_repo
- name: Add cron-job for borgmatic (large repo, check)
cron:
name: "borgmatic-check"
weekday: 0
hour: "{{ range(7, 24) |random }}"
minute: "{{ 59 |random }}"
user: "root"
cron_file: borgmatic
job: "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }} --check"
when: borgmatic_large_repo
- name: Add cron-job for borgmatic (normal-sized repo)
cron:
name: "borgmatic-create"
hour: "{{ 6 |random }}"
minute: "{{ 59 |random }}" minute: "{{ 59 |random }}"
user: "root" user: "root"
cron_file: borgmatic cron_file: borgmatic
job: "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}" job: "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}"
when: not borgmatic_large_repo
- name: Set PATH for borgmatic cron job. - name: Set PATH for borgmatic cron job.
cron: cron:

View File

@ -106,9 +106,8 @@ consistency:
# "archive" checks all of the archives, and "extract" does an extraction dry-run # "archive" checks all of the archives, and "extract" does an extraction dry-run
# of just the most recent archive. # of just the most recent archive.
checks: checks:
- disabled - repository
# - repository - archives
# - archives
# Restrict the number of checked archives to the last n. Applies only to the "archives" check. # Restrict the number of checked archives to the last n. Applies only to the "archives" check.
check_last: 3 check_last: 3