LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Sync folder with rsync (https://www.linuxquestions.org/questions/linux-server-73/sync-folder-with-rsync-793304/)

chobong 03-04-2010 09: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 09:53 PM

I think you are rsyncing to the wrong place.

You should probably do
Code:

rsync -avz -e ssh --delete /host1/abc host2
Or
Code:

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

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

chobong 03-04-2010 10: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 10:33 PM

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

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".

Cheers,

Evo2.

chobong 03-04-2010 11:02 PM

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-04-2010 11:23 PM

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).

Code:

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


All times are GMT -5. The time now is 01:12 PM.