Refactor disk-usage logic into dedicated script
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:
BeauTroll
2025-12-18 16:05:58 +01:00
parent 636f5987c7
commit 9a5ea36901
2 changed files with 44 additions and 14 deletions

View File

@@ -56,20 +56,7 @@ info: ## Affiche les informations sur le repository
@sudo bash -c 'set -a && source /etc/borgmatic/.env && set +a && borgmatic info'
disk-usage: ## Affiche l'espace disque utilisé et libre sur le serveur de backup
@echo "$(BLUE)Espace disque sur le serveur de backup:$(NC)"
@echo ""
@echo "$(YELLOW)Espace utilisé par le repository Borg (toutes archives):$(NC)"
@sudo bash -c 'set -a && source /etc/borgmatic/.env && set +a && borgmatic info 2>/dev/null | grep "All archives" | grep GB'
@echo ""
@echo "$(YELLOW)Espace libre sur le serveur distant:$(NC)"
@sudo bash -c 'set -a && source /etc/borgmatic/.env && set +a && \
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'
@sudo ./scripts/disk-usage.sh
restore: ## Lance le script de restauration interactive
@echo "$(BLUE)Restauration interactive...$(NC)"