rsync

Command

$ rsync -avz --delete-after /home/pong/rsyncsource /home/pong/rsyncdest

Options

a : Recursively transfer all files from the directory hone/pong/rsyncsource on the machine foo into the /home/pong/rsyncdest/rsyncsource directory

The files are transferred in “archive” mode, which ensures that symbolic links, devices, attributes, permissions, ownerships etc are preserved in the transfer.

v : verbose
z : compression will be used to reduce the size of data portions of the transfer.

–delete-after : delete the files that got deleted on rsyncsource on rsyncdest after transfer ( ref : http://askubuntu.com/questions/476041/how-do-i-make-rsync-delete-files-that-have-been-deleted-from-the-source-folder )

–rsh=”ssh …” : choose an alternative remote shell program to use for communication between the local and remote copies of rsync. Typically, rsync is configured to use ssh by default. However, if you would like to change an ssh encryption or change port ( ssh -p 2234 ), or change an identity file ( ssh -i /path/to/id_rsa ).

Rsync with last modified date

  • Last modified date is one of the factor that rsync use to decide to copy, if we use cp before rsync and we would like to preserve the last modified date, use the –preserve flag.

cp –preserve

Therefore, I use -c ( checksum ) instead.

NOTE : -c ( checksum ) won’t works with -a ( that alias contains -t that is checking last modified date.

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s