Wednesday, July 1, 2009

WHAT IS RSYNC

RSYNC


rsync utility is used for synchronising files one of the major adavantage of rsync is that rsync can preserve permissions and ownership information, copy symbolic links, and generally is designed to intelligently handle your files

The basic syntax for rsync is simple enough -- just run
rsync [options] source destination

If you want to rsync the contents from /home/mabin/ to /var/www/html/ the command

rsync -a /home/mabin /var/www/html

Whe doing rsync there is a big meaning in the ending '/' because if I rsync /home/mabin/ then only the contents inside the folder mabin will be copied.....but if didn't used the '/' ie /home/mabin then the entire directory will be taken ..that is a directory named mabin will be created at the destination

some switches with rsync
-----------------------------
-a --> archive option, which actually combines several rsync options. It combines the recursive and copy symlinks options, preserves group and owner, and generally makes rsync suitable for making archive copies. Note that it doesn't preserve hardlinks

-H --> Copies hard link

-v --> verbose mode

-z --> Compress option, will compress the data during transfer

--delete --> For deleting the already transferred data from source (a dangerous option, try to avoid it)

--exclude=".*/" --> To avoid copying hidden files. With this option you can avoid copying any particular file( If you dont want to copy .php files then pot it like this --exclude="*.php/"

sample command for local copying
----------------------------------------

rsync -avh /home/mabin/ /var/www/html


Rsync for remote copying
------------------------------------------------------------

rsync -avhe ssh /home/user/dir/ user@remote.host.com:dir/

If you want to know how fast the transfer is going use the --progress option

rsync --progress -avhe ssh /home/user/dir/ user@remote.host.com:dir/

No comments:

Post a Comment