Run the command according to your Linux Distro
Ubuntu or Debian:
apt-get install rsync
CentOS, Fedora or Redhat
yum install rsync
How to Use Rsync?
Syntax to use rsync is like the following:
rsync -options <source> <destination>
Some of the options that are used commonly in the rsync command:
- -v, –verbose Verbose output
- -q, –quiet To suppress output message
- -a, –archive archive while synchronizing ( -a equal to following options -rlptgoD)
- -r, –recursive To sync recursively
- -b, –backup To take the backup during sync
- -u, –update To update the files only
- -l, –links To copy symlinks as is
- -n, –dry-run To perform a dry run without actual sync
- -e, –rsh=COMMAND Mention the remote shell to use in rsync
- -z, –compress To compress data during sync
- -h, –human-readable To Display the output in a read-able format
- –progress To Show the syncing progress during transfer
Here is the example command to sync files from source server to destination server. In this example, we will be running a command on the destination server:
rsync -avz -e “ssh -p 2222” –exclude public_html/wp-content/cache/ source.hostname.com:/home/username/public_html/wordpress/ /home/backups/username/wordpress/
- Options from the above list
- Defining a different SSH Port
- Excluding a folder from sync (You can use multiple exclude in one command)
- Exclude folder path
- Source server hostname
- Source Server directory Path from where to sync files
- Destination Server Path to where sync the files.
Leave a Reply