Fix disk-usage command to handle SSH URLs with ports correctly
Some checks failed
Deploy Borgmatic Configuration / Deploy to Production Server (push) Has been cancelled

Fix the disk-usage make target to properly parse SSH URLs containing ports
and display repository statistics correctly.

Changes:
- Simplify Borg statistics parsing to show actual values
- Fix SSH connection to handle custom ports (e.g., port 23)
- Extract user@host and port separately from BORG_REPO URL
- Use ssh -p PORT syntax instead of incorrect host:port format

🤖 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 15:48:27 +01:00
parent cecc224dea
commit 9b10a325dc

View File

@@ -59,10 +59,17 @@ disk-usage: ## Affiche l'espace disque utilisé et libre sur le serveur de backu
@echo "$(BLUE)Espace disque sur le serveur de backup:$(NC)" @echo "$(BLUE)Espace disque sur le serveur de backup:$(NC)"
@echo "" @echo ""
@echo "$(YELLOW)Espace utilisé par le repository Borg:$(NC)" @echo "$(YELLOW)Espace utilisé par le repository Borg:$(NC)"
@sudo bash -c 'set -a && source /etc/borgmatic/.env && set +a && borgmatic info --json 2>/dev/null | grep -o "\"stats\":{[^}]*}" | sed "s/[{}\"]//g" | tr "," "\n" | grep -E "original_size|compressed_size|deduplicated_size" || borgmatic info | grep -E "Original size|Compressed size|Deduplicated size"' @sudo bash -c 'set -a && source /etc/borgmatic/.env && set +a && borgmatic info 2>/dev/null | grep -A1 "Original size" | head -2'
@echo "" @echo ""
@echo "$(YELLOW)Espace libre sur le serveur distant:$(NC)" @echo "$(YELLOW)Espace libre sur le serveur distant:$(NC)"
@sudo bash -c 'set -a && source /etc/borgmatic/.env && set +a && SERVER=$$(echo $$BORG_REPO | sed "s|ssh://||" | cut -d"/" -f1) && ssh $$SERVER "df -h | grep -E \"Filesystem|$$\" | head -2"' @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'
restore: ## Lance le script de restauration interactive restore: ## Lance le script de restauration interactive
@echo "$(BLUE)Restauration interactive...$(NC)" @echo "$(BLUE)Restauration interactive...$(NC)"