borg: Adapt to new borg version

Use `--glob-archives` instead of `--prefix` and add compacting the
repository.
This commit is contained in:
finga 2023-09-14 17:55:40 +02:00
parent 52de56b79d
commit f8bc3ef54b

View file

@ -47,7 +47,7 @@ info "Pruning repository"
borg prune \
--list \
--prefix '{hostname}-' \
--glob-archives '{hostname}-*' \
--show-rc \
--keep-daily 7 \
--keep-weekly 4 \
@ -55,15 +55,24 @@ borg prune \
prune_exit=$?
# actually free repo disk space by compacting segments
info "Compacting repository"
borg compact
compact_exit=$?
# use highest exit code as global exit code
global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit ))
global_exit=$(( compact_exit > global_exit ? compact_exit : global_exit ))
if [ ${global_exit} -eq 0 ]; then
info "Backup and Prune finished successfully"
info "Backup, Prune, and Compact finished successfully"
elif [ ${global_exit} -eq 1 ]; then
info "Backup and/or Prune finished with warnings"
info "Backup, Prune, and/or Compact finished with warnings"
else
info "Backup and/or Prune finished with errors"
info "Backup, Prune, and/or Compact finished with errors"
fi
exit ${global_exit}