62 lines
1.7 KiB
YAML
62 lines
1.7 KiB
YAML
|
- name: Install Borg packages
|
||
|
package:
|
||
|
name: "{{ borg_package }}"
|
||
|
state: present
|
||
|
loop: "{{ borg_packages }}"
|
||
|
loop_control:
|
||
|
loop_var: borg_package
|
||
|
|
||
|
- name: Initialize Borg repository
|
||
|
command: borg init --make-parent-dirs -e "{{ borg_encryption_mode }}" "{{ borg_repository }}"
|
||
|
environment:
|
||
|
BORG_PASSPHRASE: "{{ borg_passphrase }}"
|
||
|
changed_when: "'A repository already exists' not in _borg_backup_init.stderr"
|
||
|
failed_when: _borg_backup_init.rc >= 2 and 'A repository already exists' not in _borg_backup_init.stderr
|
||
|
register: _borg_backup_init
|
||
|
|
||
|
- name: Create Borgmatic config directory
|
||
|
file:
|
||
|
path: /etc/borgmatic
|
||
|
state: directory
|
||
|
owner: root
|
||
|
group: root
|
||
|
mode: "755"
|
||
|
|
||
|
- name: Copy Borgmatic config file
|
||
|
copy:
|
||
|
content: "{{ borgmatic_config | to_nice_yaml(indent=2) }}"
|
||
|
dest: /etc/borgmatic/config.yaml
|
||
|
owner: root
|
||
|
group: root
|
||
|
mode: "600"
|
||
|
|
||
|
- name: Add cron job for regular Borgmatic create and prune
|
||
|
cron:
|
||
|
user: root
|
||
|
name: borgmatic-create
|
||
|
cron_file: borgmatic
|
||
|
hour: "{{ borgmatic_cron_hour }}"
|
||
|
minute: "{{ borgmatic_cron_minute }}"
|
||
|
state: present
|
||
|
job: borgmatic --create --prune
|
||
|
|
||
|
- name: Add cron job for unfrequent Borgmatic check
|
||
|
cron:
|
||
|
user: root
|
||
|
name: borgmatic-check
|
||
|
cron_file: borgmatic
|
||
|
weekday: "{{ borgmatic_check_cron_weekday }}"
|
||
|
hour: "{{ borgmatic_check_cron_hour }}"
|
||
|
minute: "{{ borgmatic_check_cron_minute }}"
|
||
|
state: present
|
||
|
job: borgmatic --check
|
||
|
|
||
|
- name: Set PATH for Borgmatic cron job.
|
||
|
cron:
|
||
|
user: root
|
||
|
name: PATH
|
||
|
cron_file: borgmatic
|
||
|
env: yes
|
||
|
state: present
|
||
|
value: /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|