From f8bc3ef54b0a2f9db8bd30538c6d10d242b2ca53 Mon Sep 17 00:00:00 2001 From: finga Date: Thu, 14 Sep 2023 17:55:40 +0200 Subject: [PATCH] borg: Adapt to new borg version Use `--glob-archives` instead of `--prefix` and add compacting the repository. --- borg_backup.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/borg_backup.sh b/borg_backup.sh index ca25d89..dfac98e 100755 --- a/borg_backup.sh +++ b/borg_backup.sh @@ -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}