How to copy files and directories between two unix systems using rsync

Wikipedia describes rsync as follow: “rsync” is a utility for efficiently transferring and synchronizing files between a computer and an external hard drive and across networked computers by comparing the modification times and sizes of files. It is commonly found on Unix-like operating systems. ”
“rsync” is a utility for efficiently transferring and synchronizing files between a computer and an external hard drive and across networked computers 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 applicationWikipedia

Rsync self describes as:
“a file transfer program capable of efficient remote update
via a fast differencing algorithm.”

Usage:
  • rsync [OPTION]… SRC [SRC]… DEST
  • rsync [OPTION]… SRC [SRC]… [USER@]HOST:DEST
  • rsync [OPTION]… SRC [SRC]… [USER@]HOST::DEST
  • rsync [OPTION]… SRC [SRC]… rsync://[USER@]HOST[:PORT]/DEST
  • rsync [OPTION]… [USER@]HOST:SRC [DEST]
  • rsync [OPTION]… [USER@]HOST::SRC [DEST]
  • rsync [OPTION]… rsync://[USER@]HOST[:PORT]/SRC [DEST]

The ‘:’ usages connect via remote shell, The ‘::’ and ‘rsync://’ usages connect to an rsync daemon, and require SRC or DEST to start with a module name. In our case we are going to use the remote shell
  • rsync [OPTION]… SRC [SRC]… [USER@]HOST:DEST
So, let’s suppose we have to unix systems, we can pull or push files from or to a remote server. Pulling from remote:
rsync -azP username@ip_or_hostname:/src/path/  /dest/path
Pushing to remote
rsync -azP /src/path username@ip_or_hostname:/dest/path/
Note: if you want to say “copy the content of a given directory but not the root directory” then remember to include the trailing slash at the end of the file Thats all folks. If this tip was useful, remember to leave a thumbs up. 😄

Leave a Reply

Close Menu