Tuesday, December 15, 2009

How to Synchronize a local directory with a remote directory using rsync in ubuntu

Most of the system administrators need to sync some of  their local folder to remote folder. You can do this with a simple command line utility rsync. This will synchronizes files and directories from one location to another , securely by using  delta encoding. It will synchronize files across the network by transferring only data that has changed.

Open a terminal

$sudo apt-get install rsync

$ rsync -r -a -v -e "ssh -l shibu" --delete /home/shibu/public_hrml

$ rsync -r -a -v -e "ssh -l shibu" --delete ceattingal.ac.in:/webroot/ /local/webroot 

rsync command common options

  • --delete : delete files that don't exist on sender
  • -v : Verbose
  • -z : compress file data
  • -e "ssh options" : specify the ssh as remote shell
  • -a : archive mode
  • -r : recurse into directories

No comments: