mirror of
https://github.com/borgbase/ansible-role-borgbackup.git
synced 2024-11-19 19:07:42 +01:00
Improve Borgmatic cron-job names.
This commit is contained in:
parent
6787e98f08
commit
e30ce279c4
24
README.md
24
README.md
@ -4,16 +4,20 @@ An Ansible Role that sets up automated remote backups on the target machine. Use
|
||||
|
||||
## Role Variables
|
||||
|
||||
- `borg_repository` (required): Full path to repository. Your own server or [BorgBase.com](https://www.borgbase.com) repo.
|
||||
- `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.
|
||||
- `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_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_ssh_command` (optional): Command to use instead of just "ssh". This can be used to specify ssh options.
|
||||
- `borg_encryption_passcommand` (optional): The standard output of this command is used to unlock the encryption key.
|
||||
### Required Arguments
|
||||
- `borg_repository`: Full path to repository. Your own server or [BorgBase.com](https://www.borgbase.com) repo.
|
||||
- `borg_source_directories`: List of local folders to back up.
|
||||
|
||||
### Optional Arguments
|
||||
- `borg_encryption_passphrase`: Password to use for repokey or keyfile. Empty if repo is unencrypted.
|
||||
- `borgmatic_config_name`: Name to use for the borgmatic config file. Defaults to `config.yml`
|
||||
- `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`
|
||||
- `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.
|
||||
- `borg_ssh_command`: Command to use instead of just "ssh". This can be used to specify ssh options.
|
||||
- `borg_encryption_passcommand`: The standard output of this command is used to unlock the encryption key.
|
||||
|
||||
## Example Playbook
|
||||
|
||||
|
@ -3,6 +3,7 @@ borg_encryption_passphrase: ''
|
||||
borg_exclude_patterns: []
|
||||
borgmatic_config_name: config.yaml
|
||||
borgmatic_large_repo: false
|
||||
borgmatic_failure_command: echo "`date` - Error while creating a backup."
|
||||
borg_one_file_system: true
|
||||
borg_exclude_from: []
|
||||
borg_encryption_passcommand: false
|
||||
|
@ -46,35 +46,37 @@
|
||||
dest: "/etc/borgmatic/{{ borgmatic_config_name }}"
|
||||
mode: 0600
|
||||
|
||||
- name: Add cron-job for borgmatic (large repo, create and prune)
|
||||
cron:
|
||||
name: "borgmatic-create"
|
||||
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"
|
||||
- name: Add cron-job for borgmatic (large repo, create and check separate)
|
||||
block:
|
||||
- cron:
|
||||
name: "borgmatic"
|
||||
hour: "{{ 6 |random }}"
|
||||
minute: "{{ 59 |random }}"
|
||||
user: "root"
|
||||
cron_file: borgmatic
|
||||
job: "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }} --create --prune"
|
||||
- cron:
|
||||
name: "borgmatic-check"
|
||||
day: "{{ 28 | random }}"
|
||||
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 }}"
|
||||
user: "root"
|
||||
cron_file: borgmatic
|
||||
job: "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}"
|
||||
block:
|
||||
- cron:
|
||||
name: "borgmatic"
|
||||
hour: "{{ 6 | random }}"
|
||||
minute: "{{ 59 | random }}"
|
||||
user: "root"
|
||||
cron_file: borgmatic
|
||||
job: "/usr/local/bin/borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}"
|
||||
- cron:
|
||||
name: "borgmatic-check"
|
||||
state: absent
|
||||
when: not borgmatic_large_repo
|
||||
|
||||
- name: Set PATH for borgmatic cron job.
|
||||
|
@ -132,4 +132,4 @@ hooks:
|
||||
|
||||
# List of one or more shell commands or scripts to execute in case an exception has occurred.
|
||||
on_error:
|
||||
- echo "`date` - Error while creating a backup."
|
||||
- {{ borgmatic_failure_command }}
|
||||
|
Loading…
Reference in New Issue
Block a user