-   Linux - Server (
-   -   Sync folder with rsync (

chobong 03-04-2010 10:46 PM

Sync folder with rsync
Dear All

I have two servers, one for my website(public) and one for testing (localhost).
Now I want to use rsync to sync these folders, so that when I update data to testing, it will update to the website automatic.
But when I use 'rsync -avz -e ssh --delete /host1/abc host2/abc' , it just sync changes on the files, not delete file.

Any ideas about this? please help me!!
Thank you so much

evo2 03-04-2010 10:53 PM

I think you are rsyncing to the wrong place.

You should probably do

rsync -avz -e ssh --delete /host1/abc host2

rsync -avz -e ssh --delete /host1/abc/ host2/abc

PS. Also, have you tried using --delete-excluded?

chobong 03-04-2010 11:16 PM

Thanks evo2!

I used this command
rsync -avz -e ssh --delete --exclude=".*" abc/* host2:/def/
Because I didn't put the same name on the servers.

That is the reason?

evo2 03-04-2010 11:33 PM

I think you can avoid using the wildcard, by using the following form:

rsync -avz -e ssh --delete abc/ host2:/def
This will copy everything inside abc on the localhost into the def directory on host2.

The trailing slash has a sort of special meaning in rsync. It is explained in the man page: look for "trailing slash".



chobong 03-05-2010 12:02 AM

Thanks evo2, again :)

I used exclude=".*" because I want to sync without hidden files.
My local_server is using SVN on 'abc' at localhost, but just wanna update the source to the server, not the svn_files.

Do you any ideas about this ?

evo2 03-05-2010 12:23 AM

I see. In that case I think you can use -C flag (--cvs-exclude) which tries ignore version control system files (cvs, svn, rcs etc).


rsync -avzC -e ssh --delete abc/ host2:/def

All times are GMT -5. The time now is 10:45 PM.