sauvegardes/bin/doprunes

29 lines
992 B
Bash
Executable File

#!/bin/bash
echo "================================================================================"
echo " Prunes du "$(date)
echo "================================================================================"
START_TIME=$(date +"%s")
START_SIZE=$(du -s /var/backups/borg/ | awk '{ print $1 }')
borgmatic prune --stats --list --verbosity 1
# Only last borgmatic version has the compact command.
cd /var/backups/borg/
for REPO in $( ls -d *.repo ); do
echo "Compact $REPO"
borg compact "$REPO"
done
chown -R borg.borg /var/backups/borg/*.repo
df -h /var/backups/borg/.
echo "====="
DURATION=$(($(date +"%s")-$START_TIME))
DURATION=$(printf "%02d:%02d:%02d" $((DURATION/60/60)) $((DURATION/60%60)) $((DURATION%60)))
END_SIZE=$(du -s /var/backups/borg/ | awk '{ print $1 }')
DIFF_SIZE=$(((END_SIZE-START_SIZE)/1024))
echo "Ended at: "$(date)" Duration: $DURATION Size: $DIFF_SIZE MB"
echo "================================================================================"