65 lines
1.8 KiB
Bash
Executable File
65 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
SCRIPT_NAME="$(basename "$0")"
|
|
|
|
roundn()
|
|
{
|
|
echo $(echo "($1+0.5)/1" | bc)
|
|
}
|
|
|
|
convert_duration()
|
|
{
|
|
local input="$1"
|
|
local minutes
|
|
if [[ $input =~ ([0-9]+)\ minutes ]]; then
|
|
minutes=${BASH_REMATCH[1]}
|
|
else
|
|
minutes=0
|
|
fi
|
|
local seconds
|
|
if [[ $input =~ ([0-9\.]+)\ seconds ]]; then
|
|
seconds=${BASH_REMATCH[1]}
|
|
seconds=$(roundn $seconds)
|
|
else
|
|
seconds=0
|
|
fi
|
|
printf "00:%02d:%02d\n" ${minutes} ${seconds}
|
|
|
|
}
|
|
|
|
#
|
|
export BORG_PASSCOMMAND="cat /srv/borg/.borg-passphrase"
|
|
|
|
BORG_REPOS="/var/backups/borg/"
|
|
cd $BORG_REPOS
|
|
ARCHIVE_COUNT=0
|
|
REPO_COUNT=0
|
|
echo "COMPUTER COUNT Original Compressed Deduplicat Last Diff Duration"
|
|
for BORG_REPO in $(ls -d *.repo); do
|
|
if [ -d "$BORG_REPO" ]; then
|
|
#echo "== $BORG_REPO"
|
|
REPO_COUNT=$(( REPO_COUNT +1))
|
|
|
|
COMPUTER=$(printf "%-40s" ${BORG_REPO::-5})
|
|
LIST=$(borg list "$BORG_REPO")
|
|
COUNT=$(echo "$LIST" | wc -l)
|
|
LAST=$(echo "$LIST" | sort -h | tail -1 | awk '{ print $1}' )
|
|
SIZE_LINE=$(borg info "$BORG_REPO" | head -8 | tail -1)
|
|
ORIGINAL_SIZE=$(echo "$SIZE_LINE" | awk '{ print $3" "$4 }')
|
|
COMPRESSED_SIZE=$(echo "$SIZE_LINE" | awk '{ print $5" "$6 }')
|
|
DEDUP_SIZE=$(echo "$SIZE_LINE" | awk '{ print $7" "$8 }')
|
|
SIZES="${SIZE_LINE:13}"
|
|
INFOS=$(borg info "${BORG_REPO}::${LAST}")
|
|
DURATION=$(echo "$INFOS" | grep Duration)
|
|
DURATION=$(convert_duration "${DURATION:10}")
|
|
DIFF_SIZE=$(echo "$INFOS" | grep "This archive" | awk '{ print $7" "$8}')
|
|
printf "%-40s %2d %10s %10s %10s %s %10s %s\n" "$COMPUTER" "$COUNT" "$ORIGINAL_SIZE" "$COMPRESSED_SIZE" "$DEDUP_SIZE" "$LAST" "$DIFF_SIZE" "$DURATION"
|
|
|
|
ARCHIVE_COUNT=$((ARCHIVE_COUNT+COUNT))
|
|
fi
|
|
done
|
|
echo "Total repository count: "$REPO_COUNT
|
|
echo "Total archive count: "$ARCHIVE_COUNT
|
|
echo "Total disk size: "$(du -sh .)
|
|
df -h /var/backups/borg/.
|