Make cron fully times configureable. By @em0lar

This commit is contained in:
em0lar 2020-07-15 05:40:38 +02:00 committed by GitHub
parent 10521fe838
commit 51e89d6e24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 7 deletions

View File

@ -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_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). - `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. - `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 ### 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. 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.

View File

@ -27,3 +27,8 @@ bb_quota_size: 0
bb_alertdays: 0 bb_alertdays: 0
bb_repo_name: "{{ inventory_hostname }}" bb_repo_name: "{{ inventory_hostname }}"
bb_sshkey: "{{ root_user['ssh_public_key'] }}" 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 }}"

View File

@ -80,17 +80,17 @@
- name: Add cron job for regular create and prune - name: Add cron job for regular create and prune
cron: cron:
name: "borgmatic" name: "borgmatic"
hour: "{{ 6 |random }}" hour: "{{ borgmatic_cron_hour }}"
minute: "{{ 59 |random }}" minute: "{{ borgmatic_cron_minute }}"
user: "root" user: "root"
cron_file: borgmatic cron_file: borgmatic
job: "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }} --create --prune" job: "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }} --create --prune"
- name: Add cron job for infrequent checks - name: Add cron job for infrequent checks
cron: cron:
name: "borgmatic-check" name: "borgmatic-check"
day: "{{ 28 | random }}" day: "{{ borgmatic_cron_checks_day }}"
hour: "{{ range(7, 24) | random }}" hour: "{{ borgmatic_cron_checks_hour }}"
minute: "{{ 59 | random }}" minute: "{{ borgmatic_cron_checks_minute }}"
user: "root" user: "root"
cron_file: borgmatic cron_file: borgmatic
job: "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }} --check" 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 - name: Add cron job for create, check and prune
cron: cron:
name: "borgmatic" name: "borgmatic"
hour: "{{ 6 | random }}" hour: "{{ borgmatic_cron_hour }}"
minute: "{{ 59 | random }}" minute: "{{ borgmatic_cron_minute }}"
user: "root" user: "root"
cron_file: borgmatic cron_file: borgmatic
job: "/usr/local/bin/borgmatic" job: "/usr/local/bin/borgmatic"