LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 09:46 PM   #1
chobong
Member
 
Registered: Jan 2010
Posts: 90

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, 09:53 PM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
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 09:54 PM. Reason: Ps
 
Old 03-04-2010, 10:16 PM   #3
chobong
Member
 
Registered: Jan 2010
Posts: 90

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, 10:33 PM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
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-04-2010, 11:02 PM   #5
chobong
Member
 
Registered: Jan 2010
Posts: 90

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-04-2010, 11:23 PM   #6
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
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



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 09:41 AM
Sync files not folders with rsync (non recursive) ehlers Linux - Software 7 03-11-2009 09:53 AM
Rsync configuration problems... backup not sync ESC201 Linux - Software 2 01-28-2009 03:19 PM
How can I use rsync to keep multiple clients in sync? BadTim Linux - Software 17 02-01-2008 04:07 AM
RSYNC Automatic sync script penguinpages Fedora 0 05-01-2007 11:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:27 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
Open Source Consulting | Domain Registration