random-shell-scripts/list_borg_archive_sizes.sh

18 lines
833 B
Bash

#!/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