LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 03-04-2010, 10:46 PM   #1
chobong
Member
 
Registered: Jan 2010
Posts: 83

Rep: Reputation: 15
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
 
Old 03-04-2010, 10:53 PM   #2
evo2
Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,588

Rep: Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227
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?

Last edited by evo2; 03-04-2010 at 10:54 PM. Reason: Ps
 
Old 03-04-2010, 11:16 PM   #3
chobong
Member
 
Registered: Jan 2010
Posts: 83

Original Poster
Rep: Reputation: 15
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?
 
Old 03-04-2010, 11:33 PM   #4
evo2
Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,588

Rep: Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227
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.
 
Old 03-05-2010, 12:02 AM   #5
chobong
Member
 
Registered: Jan 2010
Posts: 83

Original Poster
Rep: Reputation: 15
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 ?
 
Old 03-05-2010, 12:23 AM   #6
evo2
Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,588

Rep: Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227Reputation: 1227
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
rsync - sync files modified within the last 60 days boomklever Linux - Networking 3 06-03-2009 10:41 AM
Sync files not folders with rsync (non recursive) ehlers Linux - Software 7 03-11-2009 10:53 AM
Rsync configuration problems... backup not sync ESC201 Linux - Software 2 01-28-2009 04:19 PM
How can I use rsync to keep multiple clients in sync? BadTim Linux - Software 17 02-01-2008 05:07 AM
RSYNC Automatic sync script penguinpages Fedora 0 05-01-2007 12:52 PM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration