diff options
| author | Colin Wilk <colin@wilk.cx> | 2026-09-01 21:01:05 +0200 |
|---|---|---|
| committer | Colin Wilk <colin@wilk.cx> | 2026-09-01 21:43:57 +0200 |
| commit | 9c7586c7c3a235672ec6490d1a8bc44a222ce5d1 (patch) | |
| tree | 8b36c5ee3105da2ae769c0d9cd96683d213c949d /templates/borg_prune_script.j2 | |
| parent | fa137a92e1084a07608a4008ec0cb891baa76774 (diff) | |
| download | ansible-role-borgbackup-9c7586c7c3a235672ec6490d1a8bc44a222ce5d1.tar.gz ansible-role-borgbackup-9c7586c7c3a235672ec6490d1a8bc44a222ce5d1.zip | |
Add borg prune and compact jobs
Run repository retention either after a successful backup or from a
dedicated systemd timer. Clean up script generation with templates and
expand molecule test coverage.
BREAKING CHANGE: Aggregate backup scripts are no longer managed, and
state=preset now requires at least one readable included directory.
Diffstat (limited to 'templates/borg_prune_script.j2')
| -rw-r--r-- | templates/borg_prune_script.j2 | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/templates/borg_prune_script.j2 b/templates/borg_prune_script.j2 new file mode 100644 index 0000000..bc1f5b9 --- /dev/null +++ b/templates/borg_prune_script.j2 @@ -0,0 +1,71 @@ +#!/bin/bash +export BORG_PASSPHRASE={{ borg_passphrase | quote }} +{% if borg_ssh_key_per_repo %} +export BORG_RSH="ssh -i {{ borg_ssh_key_path }}" +{% endif %} + +borg prune \ + {% if borg_prune_force %} +--force \ + {% endif %} +{% if borg_prune_stats %} +--stats \ + {% endif %} +{% if borg_prune_list %} +--list \ + {% endif %} +{% if borg_prune_save_space %} +--save-space \ + {% endif %} +--checkpoint-interval {{ borg_prune_checkpoint_interval }} \ + --glob-archives {{ borg_prune_glob_archives | quote }} \ + {% if borg_prune_keep_within %} +--keep-within {{ borg_prune_keep_within | quote }} \ + {% endif %} +{% if borg_prune_keep_last %} +--keep-last {{ borg_prune_keep_last | quote }} \ + {% endif %} +{% if borg_prune_keep_minutely %} +--keep-minutely {{ borg_prune_keep_minutely | quote }} \ + {% endif %} +{% if borg_prune_keep_hourly %} +--keep-hourly {{ borg_prune_keep_hourly | quote }} \ + {% endif %} +{% if borg_prune_keep_daily %} +--keep-daily {{ borg_prune_keep_daily | quote }} \ + {% endif %} +{% if borg_prune_keep_weekly %} +--keep-weekly {{ borg_prune_keep_weekly | quote }} \ + {% endif %} +{% if borg_prune_keep_monthly %} +--keep-monthly {{ borg_prune_keep_monthly | quote }} \ + {% endif %} +{% if borg_prune_keep_13weekly %} +--keep-13weekly {{ borg_prune_keep_13weekly | quote }} \ + {% endif %} +{% if borg_prune_keep_3monthly %} +--keep-3monthly {{ borg_prune_keep_3monthly | quote }} \ + {% endif %} +{% if borg_prune_keep_yearly %} +--keep-yearly {{ borg_prune_keep_yearly | quote }} \ + {% endif %} +{% if borg_prune_additional_arguments %} +{{ borg_prune_additional_arguments }} \ + {% endif %} +{{ borg_server_user }}@{{ borg_server_host_url }}:{{ borg_server_user_home }}/{{ borg_repo_name }} +borg_prune_exit=$? +if [ "${borg_prune_exit}" -ne 0 ]; then + exit "${borg_prune_exit}" +fi +{% if borg_prune_compact_enabled %} + +borg compact \ + {% if borg_compact_cleanup_commits %} +--cleanup-commits \ + {% endif %} +--threshold {{ borg_compact_threshold }} \ + {% if borg_compact_additional_arguments %} +{{ borg_compact_additional_arguments }} \ + {% endif %} +{{ borg_server_user }}@{{ borg_server_host_url }}:{{ borg_server_user_home }}/{{ borg_repo_name }} +{% endif %} |