Rsync is a linux application to sync files between linux servers. It is not installed by default, so to use this command, you have to install it using following commands.

Install Rsync on server

Debian Linux user type the following command:

# apt-get install rsync

Fedora Linux user, user type the following command:

# yum install rsync

Red Hat Linux user, user type the following command:

# up2date rsync

FreeBSD user, user type the following command:

# pkg_add -r -v rsync

ALTERNATIVELY, use FreeBSD ports collection:

# cd /usr/ports/net/rsync
# make; make install; make clean

Basic usage to update files on a remove server

rsync -avrR --links --rsh=/usr/bin/ssh /var/html
  • -avrR : archive mode (a), verbose (v), recurse into directories (r), use relative path names (R)
  • –links : copy symlinks as symlinks
  • –rsh=/usr/bin/ssh : Use to specify the remote shell ssh to use (secure copy).
  • : WWW2 server IP address and path to synchronize to www1 server
  • /var/html : WWW1 server path

Using rsync in a shell script to synchronize files

rsync -avrR --links --rsh=$SSH $MASTER:$DIR $LDIR

You can find more information on rsync official site. You can find more options here and more great linux tricks here. Looking for backing up your files on linux, you can read more about it here.