export remote='root@zajnb01-kvm5f.mirror.ad.company.co.za'; export dstdev=`ssh -i /root/.ssh/rsync_rsa $remote "rbd map rbd_ssd/vm-277-disk-0`; [ -z $srcdev ] && exit 1"; # or map the image on the destination host and program the variable manually on the source system, for example: # export dstdev='/dev/rbd320'; ssh -i /root/.ssh/rsync_rsa $remote " perl -'MDigest::MD5 md5' -ne 'BEGIN{\$/=\4194304};print md5(\$_)' $dstdev | lzop -c" | lzop -dc | perl -'MDigest::MD5 md5' -ne 'BEGIN{$/=\4194304};$b=md5($_); read STDIN,$a,16;if ($a eq $b) {print "s"} else {print "c" . $_}' $srcdev | lzop -c | ssh -i /root/.ssh/rsync_rsa $remote "lzop -dc | perl -ne 'BEGIN{\$/=\1} if (\$_ eq\"s\") {\$s++} else {if (\$s) { seek STDOUT,\$s*4194304,1; \$s=0}; read ARGV,\$buf,4194304; print \$buf}' 1<> $dstdev";