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

Post Reply
User avatar
Eli
Senior Expert Member
Reactions: 183
Posts: 5334
Joined: 9 years ago
Location: Tanzania
Has thanked: 75 times
Been thanked: 88 times
Contact:

#1

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.
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
User avatar
Eli
Senior Expert Member
Reactions: 183
Posts: 5334
Joined: 9 years ago
Location: Tanzania
Has thanked: 75 times
Been thanked: 88 times
Contact:

#2

0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
Post Reply

Return to “Linux and Unix Based Operating Systems”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 6 guests