Rsync Commands

rsync -avnh source target

#Use rsync to sync to remote system as user over remote shell compressing transfer and without crossing filesystem boundaries
rsync -avzx -e ssh /var/www/ user@remote_host:/var/www/

#Use rsync to sync to remote system as user over remote shell skipping files that are newer on the remote server
rsync -avzxu -e ssh /var/www/ user@remote_host:/var/www/

Pushing files with rsync
rsync -a ~/dir1 user@remote_host:/var/www/

Pulling files with rsync
rsync -a user@remote_host:/home/user/dir1 /var/www

#To see which files need to be synced:
rsync -n –dry-run -av /var/www/vhosts/domain.com/. remote_host:/var/www/vhosts/domain.com/.

 

-a = archive which basically means use recursion and preserve symbolic links, devices, attributes, permissions, ownerships, etc.(not hard links)
-v = verbose
-z = compression
-n = dry run
-h = human readable
-P = progress bar for the transfers and allows you to resume interrupted transfers
-u = skip files that are newer on the receiver
–delete option allows deletions from destination if not in source
–dry-run
–exclude=pattern_to_exclude excludes items matching the pattern (Good practice to run with –dry-run first to be sure)

* By default, rsync does not delete anything from the destination directory.
 

About vicki

Welcome to the Sovereign Republic of Vickistan. I am the President here. Lucky me! No taxes or laws yet. Lucky you!
This entry was posted in Linux. Bookmark the permalink.