Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Replace grep-based parsing with awk to properly capture header and data lines without duplicates. Changes: - Use awk to capture header line (Original/Compressed/Deduplicated size) - Print header followed by matching "All archives" line with sizes - Exit immediately after first match to prevent duplicates 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
44 lines
1.1 KiB
Bash
Executable File
44 lines
1.1 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 | awk '/Original size.*Compressed size.*Deduplicated size/{header=$0; next} /All archives:.*[GT]B/{if(header) print header; print; exit}'
|
|
|
|
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
|