Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Include the column headers (Original size, Compressed size, Deduplicated size) in the disk-usage output for better readability. Changes: - Use grep -B1 to capture header line before "All archives" - Display both header and data lines 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
44 lines
1.0 KiB
Bash
Executable File
44 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Script d'affichage de l'espace disque du serveur de backup
|
|
# Usage: ./disk-usage.sh
|
|
#
|
|
|
|
set -e
|
|
|
|
# Couleurs
|
|
BLUE='\033[0;34m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m'
|
|
|
|
# Charger et exporter les variables d'environnement
|
|
if [ -f /etc/borgmatic/.env ]; then
|
|
set -a
|
|
source /etc/borgmatic/.env
|
|
set +a
|
|
elif [ -f .env ]; then
|
|
set -a
|
|
source .env
|
|
set +a
|
|
fi
|
|
|
|
echo -e "${BLUE}Espace disque sur le serveur de backup:${NC}"
|
|
echo ""
|
|
|
|
# Statistiques du repository Borg
|
|
echo -e "${YELLOW}Espace utilisé par le repository Borg (toutes archives):${NC}"
|
|
borgmatic info 2>/dev/null | grep -B1 "All archives" | grep -E "Original size|All archives" | head -2
|
|
|
|
echo ""
|
|
|
|
# Espace libre sur le serveur distant
|
|
echo -e "${YELLOW}Espace libre sur le serveur distant:${NC}"
|
|
USER_HOST=$(echo $BORG_REPO | sed "s|ssh://||" | sed "s|:.*||")
|
|
PORT=$(echo $BORG_REPO | grep -o ":[0-9]*/" | sed "s|[:/]||g")
|
|
|
|
if [ -n "$PORT" ]; then
|
|
ssh -p $PORT $USER_HOST "df -h ~/ | tail -1"
|
|
else
|
|
ssh $USER_HOST "df -h ~/ | tail -1"
|
|
fi
|