aboutsummaryrefslogtreecommitdiffstats
path: root/defaults/main.yml
diff options
context:
space:
mode:
authorColin Wilk <colin@wilk.cx>2026-09-01 21:01:05 +0200
committerColin Wilk <colin@wilk.cx>2026-09-01 21:43:57 +0200
commit9c7586c7c3a235672ec6490d1a8bc44a222ce5d1 (patch)
tree8b36c5ee3105da2ae769c0d9cd96683d213c949d /defaults/main.yml
parentfa137a92e1084a07608a4008ec0cb891baa76774 (diff)
downloadansible-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 'defaults/main.yml')
-rw-r--r--defaults/main.yml93
1 files changed, 84 insertions, 9 deletions
diff --git a/defaults/main.yml b/defaults/main.yml
index 1c9d05d..1872e8b 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -144,8 +144,67 @@ borg_compression: zstd
# See: https://borgbackup.readthedocs.io/en/stable/usage/create.html
borg_create_additional_arguments: ""
+################################################################################
+# Borg Prune / Compact Configuration
+# See: https://borgbackup.readthedocs.io/en/stable/usage/prune.html
+# See: https://borgbackup.readthedocs.io/en/stable/usage/compact.html
+################################################################################
+
+# Enable repository retention management for this backup job.
+borg_prune_enabled: false
+
+# How prune is triggered:
+# - after_backup: start the dedicated prune service after a successful backup
+# - timer: start the dedicated prune service from its own timer
+borg_prune_trigger: after_backup
+
+# Additional arguments passed to `borg prune`.
+borg_prune_additional_arguments: ""
+
+# Restrict prune to a subset of archives within the repository.
+borg_prune_glob_archives: "{hostname}-*"
+
+# Force pruning of corrupted archives.
+borg_prune_force: false
+
+# Print deletion statistics after prune.
+borg_prune_stats: true
+
+# Print verbose keep/prune output.
+borg_prune_list: false
+
+# Work slower but use less space while pruning.
+borg_prune_save_space: false
+
+# Write checkpoint every N seconds while pruning.
+borg_prune_checkpoint_interval: 1800
+
+# Borg retention rules. Set to empty string to omit an option.
+borg_prune_keep_within: ""
+borg_prune_keep_last: ""
+borg_prune_keep_minutely: ""
+borg_prune_keep_hourly: ""
+borg_prune_keep_daily: ""
+borg_prune_keep_weekly: ""
+borg_prune_keep_monthly: ""
+borg_prune_keep_13weekly: ""
+borg_prune_keep_3monthly: ""
+borg_prune_keep_yearly: ""
+
+# Run `borg compact` after prune. This is needed to actually free disk space.
+borg_prune_compact_enabled: true
+
+# Additional arguments passed to `borg compact`.
+borg_compact_additional_arguments: ""
+
+# Remove old 17-byte commit-only segments before compaction.
+borg_compact_cleanup_commits: false
+
+# Minimum saved-space threshold in percent for compaction.
+borg_compact_threshold: 10
+
# This is a list of files and directories to be backed up in the systemd job.
-# In case you leave this empty, the role will not create an automatic backup job
+# This must not be empty when state=present.
borg_included_dirs: []
# This is a list of files and directories that you wish to have excluded from
@@ -177,17 +236,16 @@ borg_passphrase: ""
# Set to empty string to disable exporting decryption keys entirely.
borg_decryption_keys_yaml_path: "{{ inventory_dir }}/decryption_keys.yml"
-# The role creates a script for backing up with the configured parameters that
-# the regular systemd service then executes. This specifies the default location
-# and name where the script is stored. By default, we store it as
-# `/usr/local/bin/run_borg_backup` so that you can run `run_borg_backup` from
-# your shell to create manual backups.
-# When you use multiple backups, this script will trigger all of them. You can
-# trigger them individually by calling
-# {{ borg_backup_script_location }}@{{ borg_backup_argument }}.
+# Base path for repository-specific backup scripts. Unless
+# borg_backup_argument is empty, the role appends @{{ borg_backup_argument }}.
+# Each script contains exactly one backup job and is used by its systemd service.
# See: `borg_backup_argument` variable.
borg_backup_script_location: /usr/local/bin/run_borg_backup
+# Base path for repository-specific prune/compact scripts. Unless
+# borg_backup_argument is empty, the role appends @{{ borg_backup_argument }}.
+borg_prune_script_location: /usr/local/bin/run_borg_prune
+
################################################################################
# Borg Backup SystemD configuration
################################################################################
@@ -202,6 +260,12 @@ borg_backup_timer_name: borg_backup
# will be called {{ borg_backup_service_name }}@{{ borg_backup_argument }}
borg_backup_service_name: borg_backup
+# Name of the systemd timer that is created when borg_prune_trigger=timer.
+borg_prune_timer_name: borg_prune
+
+# Name of the systemd service created when pruning is enabled.
+borg_prune_service_name: borg_prune
+
# Includes a list of successful exit codes that are accepted as a successful
# backup and not throw a systemd failure in addition to exit code 0.
#
@@ -220,6 +284,11 @@ borg_backup_service_name: borg_backup
# https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html#SuccessExitStatus=
borg_backup_service_successful_exit_status: []
+# Includes a list of successful exit codes accepted by the dedicated prune
+# service in addition to exit code 0. This has the same format and behavior as
+# borg_backup_service_successful_exit_status.
+borg_prune_service_successful_exit_status: []
+
# The backup argument is appended to systemd timer / systemd service and the
# backup script. It is used to distinguish backup targets from one another
# meaning it should be unique per target.
@@ -236,3 +305,9 @@ borg_systemd_oncalendar: "*-*-* 02:00:00"
# to distribute the load on the backup server. For more information on how to
# configure this see: systemd.timer(5)
borg_systemd_accuracysec: 60min
+
+# Schedule for the prune timer when borg_prune_trigger=timer.
+borg_prune_systemd_oncalendar: "*-*-* 03:30:00"
+
+# Accuracy for the prune timer when borg_prune_trigger=timer.
+borg_prune_systemd_accuracysec: 60min