2024-03-08 16:35:07 +01:00
|
|
|
- name:
|
|
|
|
become: true
|
|
|
|
block:
|
|
|
|
- name: Backup SQLite database
|
|
|
|
command:
|
|
|
|
cmd: |
|
|
|
|
sqlite3
|
|
|
|
"{{ volumes['uptime_kuma_datadir'] }}/kuma.db"
|
|
|
|
".backup {{ volumes['uptime_kuma_datadir'] }}/kuma-backup.db"
|
|
|
|
|
|
|
|
- name: Create borg backup
|
|
|
|
command:
|
|
|
|
cmd: |
|
|
|
|
borg create
|
|
|
|
--compression=lzma
|
|
|
|
"{{ borg_repodir }}::{{ role_name }}-{now:%Y-%m-%d_%H-%M-%S}"
|
|
|
|
{{ volumes['uptime_kuma_datadir'] }}/kuma-backup.db
|
|
|
|
environment:
|
|
|
|
BORG_PASSCOMMAND: "cat {{ borg_passphrase_file }}"
|
|
|
|
|
2024-03-16 18:58:40 +01:00
|
|
|
# The kuma-backup.db file is owned by root which causes
|
|
|
|
# users['uptime_kuma'] to try to take ownership when it cannot.
|
|
|
|
- name: Delete temporary backup file
|
|
|
|
file:
|
|
|
|
path: "{{ volumes['uptime_kuma_datadir'] }}/kuma-backup.db"
|
|
|
|
state: absent
|
|
|
|
|
2024-03-08 16:35:07 +01:00
|
|
|
- name: Prune borg repository
|
|
|
|
command:
|
|
|
|
cmd: |
|
|
|
|
borg prune
|
|
|
|
--glob-archives='{{ role_name }}-*'
|
|
|
|
{{ borg_prune_options }}
|
|
|
|
{{ borg_repodir }}
|
|
|
|
environment:
|
|
|
|
BORG_PASSCOMMAND: "cat {{ borg_passphrase_file }}"
|