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_<key>.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 <noreply@anthropic.com>
This commit is contained in:
@@ -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" <<LISTENER
|
||||
#!/bin/bash
|
||||
nc -l -p $port | zstd -d | tar $tar_extract_opts 2>/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" <<LISTENER
|
||||
#!/bin/bash
|
||||
nc -l -p $port | zstd -d | tar $tar_extract_opts 2>/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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user