diff --git a/README.md b/README.md index 442f160..e710e0d 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,12 @@ $ git clone https://github.com/borgbase/ansible-role-borgbackup.git roles/borgba - `borg_encryption_passcommand`: The standard output of this command is used to unlock the encryption key. - `borg_retention_policy`: Retention policy for how many backups to keep in each category (daily, weekly, monthly, etc). - `ssh_key_file`: Path to a private ssh key file (default is `.ssh/id_ed25519`). It generates a ed25519 key if the file doesn't exist yet. +- `borgmatic_cron_hour`: Hour when regular create and prune cron job will run. Defaults to `{{ 6 | random }}` +- `borgmatic_cron_minute`: Minute when regular create and prune cron job will run. Defaults to `{{ 59 | random }}` +- `borgmatic_cron_checks_day`: Day when cron job for infrequent checks will run. Defaults to `{{ 28 | random }}` +- `borgmatic_cron_checks_hour`: Hour when cron job for infrequent checks will run. Defaults to `{{ range(7, 24) | random }}` +- `borgmatic_cron_checks_minute`: Minute when cron job for infrequent checks will run. Defaults to `{{ 59 | random }}` + ### Optional Arguments for [BorgBase.com](https://www.borgbase.com) repository auto creation This role can also set up a new repository on BorgBase, using the arguments below. Thanks to [Philipp Rintz](https://github.com/p-rintz) for contribution this feature. diff --git a/defaults/main.yml b/defaults/main.yml index 7779e5c..1f1d1ea 100755 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -27,3 +27,8 @@ bb_quota_size: 0 bb_alertdays: 0 bb_repo_name: "{{ inventory_hostname }}" bb_sshkey: "{{ root_user['ssh_public_key'] }}" +borgmatic_cron_hour: "{{ 6 | random }}" +borgmatic_cron_minute: "{{ 59 | random }}" +borgmatic_cron_checks_day: "{{ 28 | random }}" +borgmatic_cron_checks_hour: "{{ range(7, 24) | random }}" +borgmatic_cron_checks_minute: "{{ 59 | random }}" diff --git a/tasks/main.yml b/tasks/main.yml index 5084822..94a5df6 100755 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -80,17 +80,17 @@ - name: Add cron job for regular create and prune cron: name: "borgmatic" - hour: "{{ 6 |random }}" - minute: "{{ 59 |random }}" + hour: "{{ borgmatic_cron_hour }}" + minute: "{{ borgmatic_cron_minute }}" user: "root" cron_file: borgmatic job: "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }} --create --prune" - name: Add cron job for infrequent checks cron: name: "borgmatic-check" - day: "{{ 28 | random }}" - hour: "{{ range(7, 24) | random }}" - minute: "{{ 59 | random }}" + day: "{{ borgmatic_cron_checks_day }}" + hour: "{{ borgmatic_cron_checks_hour }}" + minute: "{{ borgmatic_cron_checks_minute }}" user: "root" cron_file: borgmatic job: "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }} --check" @@ -102,8 +102,8 @@ - name: Add cron job for create, check and prune cron: name: "borgmatic" - hour: "{{ 6 | random }}" - minute: "{{ 59 | random }}" + hour: "{{ borgmatic_cron_hour }}" + minute: "{{ borgmatic_cron_minute }}" user: "root" cron_file: borgmatic job: "/usr/local/bin/borgmatic"