diff --git a/doc/source/sysadmin.rst b/doc/source/sysadmin.rst index c81c85c153..04329d80b5 100644 --- a/doc/source/sysadmin.rst +++ b/doc/source/sysadmin.rst @@ -302,10 +302,13 @@ roll-back to a known good state; see However, we have limited backup space. Each backup server has a script ``/usr/local/bin/prune-borg-backups`` which can be run to -reclaim space. This will keep the last 7 days of backups, then -monthly backups for 1 year and yearly backups for each archive. The -backup servers will send a warning when backup volume usage is high, -at which point this can be run manually. +reclaim space. This should be run in a ``screen`` instance as it can +take a considerable time. It will prompt when run; you can confirm +the process with a ``noop`` run; confirming the prune will log the +output to ``/opt/backups``. This will keep the last 7 days of backups, +then monthly backups for 1 year and yearly backups for each archive. +The backup servers will send a warning when backup volume usage is +high, at which point this can be run manually. .. _force-merging-a-change: diff --git a/playbooks/roles/borg-backup-server/files/prune-borg-backups.sh b/playbooks/roles/borg-backup-server/files/prune-borg-backups.sh index 945c429961..0ed9142b5a 100644 --- a/playbooks/roles/borg-backup-server/files/prune-borg-backups.sh +++ b/playbooks/roles/borg-backup-server/files/prune-borg-backups.sh @@ -10,6 +10,10 @@ if [[ ${borg_op} == 'noop' ]]; then BORG_OP='--dry-run' elif [[ ${borg_op} == 'prune' ]]; then BORG_OP='' + LOG_FILE="/opt/backups/prune-$(date '+%Y-%m-%d-%H-%M-%S').log" + echo "*** Logging output to ${LOG_FILE}" + exec 1>${LOG_FILE} + exec 2>&1 else echo "*** Invalid input" exit 1 @@ -31,7 +35,7 @@ for u in borg-*; do echo echo echo "+------" - echo "| Pruning ${BORG_REPO} archive ${prefix}" + echo "| $(date) Pruning ${BORG_REPO} archive ${prefix}" echo "+------" /opt/borg/bin/borg prune --prefix ${prefix} ${BORG_OP} --verbose --list --show-rc --keep-daily 7 --keep-weekly 4 --keep-monthly 12 done