====== rsync ====== ===== between two remotes ===== Rsync cannot work with two remotes. As workaround SSH tunnel to remote host is created and rsync is spawned locally on src host. [[https://unix.stackexchange.com/questions/183504/how-to-rsync-files-between-two-remotes|How to rsync files between two remotes?]] #!/bin/bash -eux SOURCE_USER=root SOURCE_HOST=192.168.179.2 SOURCE_PATH="/public/image.iso" TARGET_USER=root TARGET_HOST=pve5 TARGET_PATH=/mnt/pve/cephfs/template/iso/ # Escape characters: SOURCE_PATH=$(printf %q "$SOURCE_PATH") TARGET_PATH=$(printf %s "$TARGET_PATH") OPTS="--recursive --times --partial --progress --verbose --update --archive --stats" OPTS="${OPTS} --bwlimit=400" OPTS="${OPTS} --compress --compress-level=9" # Test connection to accept remote host key ssh -l $TARGET_USER -A -R localhost:22000:$TARGET_HOST:22 $SOURCE_USER@$SOURCE_HOST "ssh localhost -p 22000 -l root whoami" ssh -l $TARGET_USER -A -R localhost:22000:$TARGET_HOST:22 \ $SOURCE_USER@$SOURCE_HOST "rsync -e 'ssh -p 22000' ${OPTS} \ ${SOURCE_PATH} \ $TARGET_USER@localhost:${TARGET_PATH}"