From 9898af951aab2e825f3cbd36129df90e6f4a5181 Mon Sep 17 00:00:00 2001 From: rob Date: Sat, 11 Jul 2026 02:21:34 +0000 Subject: [PATCH] clone-backup: ship the nc listener as a script file - inline bash -c quoting cannot carry --transform expressions The slowdisk --transform args contain '|' and quotes; the ssh+screen+bash -c stack strips one quoting level too many and splits the pipeline (broke the katana retry within minutes of fccf2792). A heredoc-generated /tmp/transfer_.sh is parsed exactly once on the target. Applies to both the screen and nohup listener branches; the direct-ssh fallback already had a single shell layer and stays inline. Co-Authored-By: Claude Fable 5 --- clone-backup.sh | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/clone-backup.sh b/clone-backup.sh index cefd1c7c..caecb1e7 100755 --- a/clone-backup.sh +++ b/clone-backup.sh @@ -373,15 +373,17 @@ transfer_backup() { if $SSH_CMD "$DEST_HOST" "which screen" >/dev/null 2>&1; then echo "Starting screen listener on port $port..." - # Start listener in screen session with proper escaping - # The backup file is already zstd compressed, so we just decompress and extract - # Use tar_extract_opts which may include --skip-old-files for SLOWDISK mode - $SSH_CMD "$DEST_HOST" " - screen -dmS transfer_${key} bash -c ' - nc -l -p $port | zstd -d | tar $tar_extract_opts 2>/tmp/transfer_${key}.err - echo \$? > /tmp/transfer_${key}.done - ' - " + # Ship the listener as a SCRIPT FILE. tar_extract_opts can contain quoted + # --transform expressions with '|' which inline bash -c quoting cannot + # survive across the ssh+screen layers (broke the katana retry, + # 2026-07-11). The heredoc expands locally; the target parses the script + # exactly once. + $SSH_CMD "$DEST_HOST" "cat > /tmp/transfer_${key}.sh && chmod +x /tmp/transfer_${key}.sh" </tmp/transfer_${key}.err +echo \$? > /tmp/transfer_${key}.done +LISTENER + $SSH_CMD "$DEST_HOST" "screen -dmS transfer_${key} /tmp/transfer_${key}.sh" # Give it time to start sleep 2 @@ -395,15 +397,13 @@ transfer_backup() { else echo "Screen not available, using nohup method..." - # Use nohup with proper backgrounding - # Use tar_extract_opts which may include --skip-old-files for SLOWDISK mode - $SSH_CMD "$DEST_HOST" " - nohup bash -c ' - nc -l -p $port | zstd -d | tar $tar_extract_opts 2>/tmp/transfer_${key}.err - echo \$? > /tmp/transfer_${key}.done - ' > /tmp/transfer_${key}.log 2>&1 < /dev/null & - echo \$! > /tmp/transfer_${key}.pid - " + # Script-file listener for the same quoting reason as the screen branch. + $SSH_CMD "$DEST_HOST" "cat > /tmp/transfer_${key}.sh && chmod +x /tmp/transfer_${key}.sh" </tmp/transfer_${key}.err +echo \$? > /tmp/transfer_${key}.done +LISTENER + $SSH_CMD "$DEST_HOST" "nohup /tmp/transfer_${key}.sh > /tmp/transfer_${key}.log 2>&1 < /dev/null & echo \$! > /tmp/transfer_${key}.pid" sleep 2