Add list_borg_archive_sizes.sh

This commit is contained in:
Jadowyne Ulve 2026-04-25 16:22:28 -05:00
commit 6ddf3f43b3

View File

@ -0,0 +1,18 @@
#!/bin/bash
REPO="/mnt/fileserver/borg"
PASSPHRASE_FILE="/root/.borg_passphrase"
BORG_PASSPHRASE=$(< "$PASSPHRASE_FILE")
# Print header (with fixed-width columns)
printf "%-32s | %12s | %14s | %17s\n" "Archive" "Original Size" "Compressed Size" "Deduplicated Size"
printf -- "----------------------------------+--------------+----------------+-------------------\n"
# Loop through archives
for arch in $(sudo env BORG_PASSPHRASE="$BORG_PASSPHRASE" borg list "$REPO" --short); do
# Get stats for this archive
LINE=$(sudo env BORG_PASSPHRASE="$BORG_PASSPHRASE" borg info "$REPO"::"$arch" | grep "This archive:")
ORIG=$(echo "$LINE" | awk '{print $3, $4}')
COMP=$(echo "$LINE" | awk '{print $6, $7}')
DEDUP=$(echo "$LINE" | awk '{print $9, $10}')
printf "%-32s | %12s | %14s | %17s\n" "$arch" "$ORIG" "$COMP" "$DEDUP"
done