Tag-Archive for » rsync «

Tuesday, October 07th, 2008 | Author: Angelo

Here is example of rsync command which is used to to delete all files from receiver server which are not exist on sender server.

rsync -e 'ssh -p 4000' -av --delete --progress ./path-to-sender-directory ip-of-remote-server:/path-of-receiver-directory/

Below is description of all parameters used in this command. Rsync stands for remote synchronization, -e to specify remote shell here remote shell we have used is ssh (secure shell running on port 4000), 'ssh -p 4000' consider secure shell ssh is configured on port 4000 on remote server, -a (stands for rpogDtH) & -v for verbose if you are using this command in script then you don’t need to define v, –delete to delete files that does not exist on sender.

./path-to-sender-directory path to sender directory, path to receiver directory username@ip-of-remote-server:/path-of-receiver-directory/ . Also you can use –progress it will show you progress during transfer(don’t use this parameter if you are using this command in shell script).

Also you can use –delete-after instead of –delete so files will be deleted from receiver after transfer not before but it would be better to use –delete because –delete does file deletions on the receiving side before transferring files to try to ensure that there is sufficient space on the receiving filesystem.

In addition there is one more option you can use –delete-excluded this will delete excluded files on receiver, this tells rsync to also delete any files on the receiving side that are excluded (In short you can use this parameter instead of –delete & –excluded).