Page 1 of 1

Copy Folders and/or Files with Rysnc and SSH from Desktop to Remote Server and Vice Versa

Posted: Sat Mar 14, 2020 3:31 pm
by Eli
Rsync is a utility for efficiently transferring and synchronizing files between a computer and an external hard drive and across networked computers/servers by comparing the modification times and sizes of files. It is commonly found on Unix-like operating systems. Rsync is written in C as a single-threaded application, see more.

It is possible to use secure copy (scp) with the recursive option (-r) to transfer files/folders, for example, to move files from Desktop to the remote host/server:

  1. scp -r /path/to/local/dir user@remotehost:/path/to/remote/dir


or from the remote host to the Desktop:

  1. scp -r user@remotehost:/path/to/remote/dir /path/to/local/dir


But using rsync is very powerful because it enables you to resume transfers if the connection breaks accidentally, and it intelligently transfers only the differences between files. Therefore, we can use rsync to move files from local directory on the Desktop to the remote server as:

  1. rsync -avz -e 'ssh' /path/to/local/dir user@remotehost:/path/to/remote/dir


or do vice versa:

  1. rsync -avz -e 'ssh' user@remotehost:/path/to/remote/dir /path/to/local/dir


Note that in both cases be careful of trailing slashes: moving /path/to/local/dir to remote host /path/to/remote/dir/ results in /path/to/remote/dir/dir.

Re: Copy Folders and/or Files with Rysnc and SSH from Desktop to Remote Server and Vice Versa

Posted: Sun Jan 31, 2021 9:21 pm
by Eli