LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-21-2013, 02:19 PM   #1
miros84
Member
 
Registered: Aug 2009
Location: Spain
Distribution: Debian stable, squeeze
Posts: 501

Rep: Reputation: 31
rsync 2 folders in 2 directions?


I sync folder A and remote folder B with rsync this way:

Code:
rsync /folderA /folderB
And this way all files from folderA pass to folderB.

But what about if I want to pass files from folderB to folderA too.

Other words in 2 direction. Do I need to execute another command?

Code:
rsync /folderB /folderA
Or is there some function to sync the 2 folders in both directions using only one command?
 
Old 01-21-2013, 05:30 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650
I'd recommend not syncing in both directions unless it's a one off when you're first setting it up, having two authoritative sources is confusing and prone to errors and/or data destruction.

You can simply reverse the source and destination when running the rsync command to sync the other way, it doesn't do two-way replication in one go.
 
1 members found this post helpful.
Old 01-22-2013, 01:43 AM   #3
miros84
Member
 
Registered: Aug 2009
Location: Spain
Distribution: Debian stable, squeeze
Posts: 501

Original Poster
Rep: Reputation: 31
Hi kbp,

So you mean to do the examples I made above? First sync from A to B and later sync from B to A.

With 2 differents command?
 
Old 01-22-2013, 02:28 AM   #4
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650
Yes, just try not to do it regularly.. pick one to be the master and only sync from it.
 
Old 01-22-2013, 03:24 AM   #5
miros84
Member
 
Registered: Aug 2009
Location: Spain
Distribution: Debian stable, squeeze
Posts: 501

Original Poster
Rep: Reputation: 31
That about the time between first and second command?

Code:
rsync /folderA /folderB
If it takes 5 minutes to sync


Code:
rsync /folderB /folderA
It takes 1 minutes to sync

Do I have to put sleep option between 2 commands so second command run after first is finished, or second command alwasy will run AFTER first is finished? Can you clarify this issue please?
 
Old 01-22-2013, 03:57 PM   #6
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650
No sleep is required.
 
Old 01-23-2013, 02:26 AM   #7
miros84
Member
 
Registered: Aug 2009
Location: Spain
Distribution: Debian stable, squeeze
Posts: 501

Original Poster
Rep: Reputation: 31
Does it mean that the second command will execute when the first is finished?
 
Old 01-23-2013, 02:45 AM   #8
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650
Yes .. they will run one after the other.
 
1 members found this post helpful.
Old 01-23-2013, 07:31 AM   #9
miros84
Member
 
Registered: Aug 2009
Location: Spain
Distribution: Debian stable, squeeze
Posts: 501

Original Poster
Rep: Reputation: 31
Ok, thank you for your explication.
 
Old 01-23-2013, 11:09 AM   #10
Habitual
LQ 5k Club
 
Registered: Jan 2011
Location: Nowhere near you, thank God.
Distribution: OSX Sierra
Posts: 8,570
Blog Entries: 14

Rep: Reputation: Disabled
I, being a c-li nut, have used unison is just such a manner in the past.

In a repo near you, I'll bet.

Set 2 unison profiles...

Code:
vi ~/.unison/A2B.prf
and add
Code:
# Unison preferences file
root = /folderA
root = /folderB
and the other one:
Code:
vi ~/.unison/B2A.prf
and add
Code:
# Unison preferences file
root = /folderB
root = /folderA
run either like so:
Code:
unison A2B -batch -ui text -auto
unison B2A -batch -ui text -auto
she-bang or source an alias for those 2 using each profile is quite easy.

Good luck!

Please let us know...
 
Old 01-23-2013, 03:22 PM   #11
miros84
Member
 
Registered: Aug 2009
Location: Spain
Distribution: Debian stable, squeeze
Posts: 501

Original Poster
Rep: Reputation: 31
I have tried unison few days ago and I didnot like the interface. I think is too simple and has few option for condifure.
Or meybe I dont spend too much time exploring it.
 
Old 01-30-2013, 08:51 AM   #12
Habitual
LQ 5k Club
 
Registered: Jan 2011
Location: Nowhere near you, thank God.
Distribution: OSX Sierra
Posts: 8,570
Blog Entries: 14

Rep: Reputation: Disabled
Quote:
Originally Posted by miros84 View Post
I have tried unison few days ago and I did not like the interface.
There is no "interface" if you use it in 'batch mode' as I showed you.

Solutions aren't always elegant, nor pretty but they tend to "do the job". Interface? I can run those 'batch modes' in dialog, zenity, or yad.

Using unison by itself, you get an Interface.
Use the c-li

If you want a pretty interface, try grsync
"Sample uses of grsync include: synchronize a music collection with removable devices, backup personal files to a networked drive, replication of a partition to another one, mirroring of files, etc." and I believe it'll support 'profiles' or 'jobs' that can specify direction from A to B or B to A.

HTH.

Good luck.
 
  


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
Synchronize the briefcase in both directions with rsync like windows patrick295767 Linux - General 3 07-24-2012 06:39 AM
rsync daemon or not - multiple folders yull Linux - General 4 02-24-2009 05:09 AM
rsync keeps backing up same folders over and over Red Squirrel Linux - Server 9 01-04-2009 11:37 PM
RSYNC Two Folders? carlosinfl Debian 3 09-09-2007 12:17 AM
using rsync - one of the folders in path has spaces??? jgruss Linux - Networking 10 07-07-2004 07:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:43 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration