Borg - server side archives compacter
If you manage backups using Borg Backup you might end up consuming a lot of space on your storage (local and/or remote), even if you have scheduled "borg prune" sessions, you are using deduplication/compression also at file system level, etc. etc.
To make room for more files (or, at least, trying to do so...) the "borg compact" tool could be helpful, so below you can find a bash script that let you schedule this process which will remove uneeded chunks from the archives.
#!/bin/sh
# __ SETTINGS __
# logfile where to write info - adapt as needed !
LOGFILE=/tmp/borg-compact-$(date +%Y%m%d_%s).log
# starting directory - adapt as needed !
STARTDIR="/home/"
# __OPERATIONS __
cd $STARTDIR
oIFS=$IFS
export IFS=$'\n'
touch $LOGFILE 2>/dev/null >/dev/null
FILES=$( find $STARTDIR -type f -name nonce 2>/dev/null );
for FILE in $FILES ;
do
cd $( dirname $FILE ) 2>>$LOGFILE >>$LOGFILE && \
borg compact --verbose --progress . 2>>$LOGFILE >>$LOGFILE
cd $STARTDIR 2>/dev/null >/dev/null
done
export IFS=$oIFS