From 9b10a325dc502b7d259410ce4e193936c480ed69 Mon Sep 17 00:00:00 2001 From: BeauTroll <-> Date: Thu, 18 Dec 2025 15:48:27 +0100 Subject: [PATCH] Fix disk-usage command to handle SSH URLs with ports correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b697c0f..c1b1ab8 100644 --- a/Makefile +++ b/Makefile @@ -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 "" @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 "$(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 @echo "$(BLUE)Restauration interactive...$(NC)"