Refactor disk-usage logic into dedicated script
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled
Move disk-usage functionality from Makefile to a dedicated shell script for better maintainability and consistency with other scripts. Changes: - Create scripts/disk-usage.sh with all disk usage logic - Simplify Makefile disk-usage target to call the script - Add environment loading and color formatting to script - Fix duplicate output by adding head -1 to grep chain 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
43
scripts/disk-usage.sh
Executable file
43
scripts/disk-usage.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/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 "All archives" | grep GB | head -1
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user