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'm about to transfer a large website over to a new server (CentOS on both ends) - at the moment the new server is running an old copy of all the files on there, something I think I did with SCP originally. Since making that copy, I made some changes to some of the files on the new server, and created a few as part of testing things.

I'm hoping to sync everything up again using rsync (as it seems to be the most appropriate tool), but I'm not sure how to remove everything that has been changed on the new server and replace it with the old files on the existing server, without copying a whole bunch of identical files again.

The -I syntax seems to do what I want, by ignoring dates I can get it to replace anything that's different, but how do I remove the files that shouldn't be there and get a true 1:1 copy on both ends?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Take a look at the --delete option:

--delete                delete extraneous files from dest dirs

something like this:

/usr/bin/rsync -avz --delete --ignore-existing /document/root/ user@newserver:/document/root/ 

You may also use the --checksum option instead of uses a "quick check" by default.

share|improve this answer
    
Thanks, I was a bit worried when I saw the notes about being cautious over using the delete option. I did a dry run earlier and it seemed to be what I expected. –  Matt W Nov 5 '11 at 22:16

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.