I have a directory on a remote server remote1
, mounted via sshfs. I am installing new versions of some of the files in the remote directory, which are quite large (~50M).
I am currently using
rsync -a --in-place local/file.so remote1/file.so~new
to copy the files into the remote directory, and then
rsync -a --in-place remote1/file.so~new remote1/file.so
.
The second rsync is slower than I would like and I suspect that it is downloading the file data via ssh before re-uploading them, rather than copying on the remote system.
I would prefer to keep the file.so~new
file as a backup (I am switching between the new and original file), which is why I am not using mv
.
I don't have an rsync program on the remote host, which is why I am not using a standard rsync command, but I am using rsync to avoid recopying when the file is already in place.
Are there command line options that will improve the copy speed? Would I be better off using scp or sftp? If so, how would I check that the file has not changed (time and size), so that I don't copy unnecessarily if the file is already in place.
My latest improvement is to upload two new copies and then use mv
to rename one of them. Is there no better way?
rsync
could be done much faster by usingssh
to runmv
on the remote machine e.g.ssh user@remote "mv /mydir/file.so~new /mydir/file.so"
sshfs
if you want fast file copies.ssh user@remote "cp -a /mydir/file.so~new /mydir/file.so"
. This just uses cp on the remote machine and you only have to upload the file once. For the first step you might usescp
command instead of usingsshfs
, it might be faster (and I'm sure will not be slower).