DevOps Engineer. Solutions Architect

Blog 3 Spring 2021: Rsync Command

Copying and transferring files from server to server is a common task conducted by most IT specialists. Some use cases involve creating a sufficient amount of database backups in the case of a power outage. Standard synchronization commands used are scp and rcp but come with their own set of faults.

On Unix-type operating systems, the rsync command synchronizes files from a source to a target, on a local machine or over a secure network connection. It’s an excellent substitute for rapidly copying files to a destination server. I’ll be showing a few commands and options.

Command Syntax Examples

Command Description
rsync [OPTION…] SRC… [DEST] Local use
rsync [OPTION…] [USER@]HOST:SRC… [DEST] Pulling from a remote host
rsync [OPTION…] SRC… [USER@]HOST:DEST Push to a remote host

Command Examples

Example Description
rsync -a -v –progress /test/dir/ ubuntu@testhostname:/test/dir2/ Copies local directory “/test/dir/” to the remote host “testhostname”

Rsync Options

Options Description
-v, –verbose increase verbosity
-q, –quiet suppress non-error messages
-c, –checksum Check for errors
-a, –archive archive mode
-n, –dry-run Perform a trial run of the command with no changes done
“sync -e” Pass rsync command into a remote host
–ignore-errors Ignore any present errors
-h, –human-readable output numbers in a human-readable format
–progress Show progress of rsync command output