Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have backed up a linux web server using rsync with cygwin. I now have a perfect copy of the server on my windows laptop. If i delete or modify a file on my laptop and run rsync again with cygwin will it delete/update the same file on the server? Im under the impression that if i delete/modify on the server and run rsync on my laptop it will delete/modify the local file on my laptop but does this work in reverse?

share|improve this question
11  
This is not an answer to your question, but you should have a look at unison. It's a synchronization tool that saves file state on both copies and thus allows bidirectional synchronization. There is also a cygwin package. –  Dubu Jul 6 at 15:53
1  
cis.upenn.edu/~bcpierce/unison –  Sam Jul 6 at 23:44

2 Answers 2

up vote 22 down vote accepted

Rsync does a one way sync, however it's up to you to decide which way the sync goes.

Rsync command syntax is the following:

rsync [OPTION...] SRC... [DEST]

Note that you specify sync from source to destination. Source and destination can be any local or remote path.

For example if you want to copy files from your server to your laptop you do:

rsync [OPTION...] <server-path> <laptop-path>

To sync in the opposite direction you do:

rsync [OPTION...] <laptop-path> <server-path>

So to answer your question: it depends on how you execute rsync.

If you want files to be deleted on the destination you need to use --delete option. But be careful with it, because if you make a mistake when specifying your source then you will end up removing everything on your destination. It's safer to test your sync without --delete option first and once you are happy with how it works you can add --delete option.

As suggested by masegaloeh in comments below, -n or --dry-run option may also be used to test rsync command behavior.

share|improve this answer
8  
Additional note: For testing rsync behavior, you can use parameter -n or --dry-run, so you will know which file will be deleted and modified –  masegaloeh Jul 6 at 14:26
1  
Thanks for the good explanation. –  ewwhite Jul 6 at 14:44

consider using --delete-after and not --delete, this will ensure that your receiving end will delete files after transfer, not before.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.