0

I have a variety of EC2 boxes inside an ELB, one of which is used for SVN exclusively. I currently have a script that gets called as part of the post-commit hook which is meant to sync files between various EC2's. The problem is that new files/folders are sync'd but deletes are not. I want to sync everything, deletes (files/folders), updates, etc.

Here is what I am using currently:

#!/bin/bash
rsync -avz ~/testing/* -e "ssh -i ./testing.pem" ec2-user@ipgoeshere:/home/ec2-user/testing

So again, I want everything from the source to be sync'd over to the EC2 including additions, changes, deletes, etc.

What am I missing?

Thanks!

4
  • 2
    You must use --delete switch to make rsync delete extraneous files.
    – ThoriumBR
    Oct 9 '14 at 17:35
  • rsync -rtvu --delete ~/testing/ -e "ssh -i ./testing.pem" ec2-user@ipgoeshere:/home/ec2-user/testing/ -- did the trick!
    – niczak
    Oct 9 '14 at 18:27
  • I should probably ask this as a follow up question but how do I restrict certain files from being sync'd over? Obviously any of the .svn stuff shouldn't go along w/ the sync. @ThoriumBR
    – niczak
    Oct 9 '14 at 18:37
  • ^--- Answer to that here: unix.stackexchange.com/questions/56131/…
    – niczak
    Oct 9 '14 at 18:40
1

To sync and delete files, and exclude some files, you can use --delete and --exclude:

rsync -rtvu --delete --exclude '*.svn' ~/testing/ -e "ssh -i ./testing.pem" ec2-user@ipgoeshere:/home/ec2-user/testing/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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