LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 04-07-2013, 09:25 AM   #1
longus
Member
 
Registered: Dec 2008
Posts: 49

Rep: Reputation: 3
Need to syncronize to folders on laptop and usb memory stick


Hello! A have an issue and i hope there is a simple decision.
I need to synchronize a folder on my laptop with a folder on an usb flash drive.
I think the same solution should be appropriate also to synchronize my phone pics with the desktop.
I need something simple that works without internet connection, i.e. when i insert the usb stick, the program must synchronize the files bidirectionally. Also in that case it is important to me to have control about the direction. Sometimes i write something on my laptop and go to print the file (transmitting the file through the usb stick), but in other case i have to edit some document, or gen it, from the office computer and then move the copy on my laptop. The way to manually copy and paste is sometimes boring and leads to mistakes.
Any suggestion should be appreciated!
 
Old 04-07-2013, 09:42 AM   #2
mariostg
Member
 
Registered: Apr 2011
Location: Gatineau, Quebec
Distribution: OpenBSD
Posts: 80

Rep: Reputation: 5
Have you tried unison : "Unison is a file-synchronization tool for Unix and Windows". It's in Slackbuilds
 
Old 04-07-2013, 11:43 AM   #3
eloi
Member
 
Registered: Nov 2010
Posts: 227

Rep: Reputation: 61
Assuming you have mounted the flash drive in /media/memory/

Code:
$ rsync -rLptDvu --delete /HDD/directory/ /media/memory/directory/
                                        ^                        ^
                                          (add the last slashes)
will copy form your machine to the flash drive. And

Code:
$ rsync -rLptDvu --delete /media/memory/directory/ /HDD/directory/
will do the opposite.


To fine tune:

Code:
$ man rsync

Last edited by eloi; 04-08-2013 at 05:24 AM. Reason: Error in path of example
 
Old 04-07-2013, 12:58 PM   #4
longus
Member
 
Registered: Dec 2008
Posts: 49

Original Poster
Rep: Reputation: 3
Quote:
Originally Posted by mariostg View Post
Have you tried unison : "Unison is a file-synchronization tool for Unix and Windows". It's in Slackbuilds
Thank you! It seems a good tool. Anyway is there a daemon mode of unison?

eloi, thank you too for the replay! rsync is also a solution. Probably i should try that too assigned to shortkeys.
 
Old 04-07-2013, 01:51 PM   #5
mariostg
Member
 
Registered: Apr 2011
Location: Gatineau, Quebec
Distribution: OpenBSD
Posts: 80

Rep: Reputation: 5
@longus
Not sure if unison has daemon mode. I know it operates either from the console or GUI, advise you of potential conflicts and operate bidirectionally. rsync is good too but I don't think it helps in file conflict resolution and does not work bidirectionally.
 
Old 04-07-2013, 02:53 PM   #6
Mark Pettit
Member
 
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 15.0
Posts: 619

Rep: Reputation: 299Reputation: 299Reputation: 299
Unison is great - but quite complex to setup. I strongly suggest you look at the rsync tips above.
 
Old 04-07-2013, 03:08 PM   #7
mariostg
Member
 
Registered: Apr 2011
Location: Gatineau, Quebec
Distribution: OpenBSD
Posts: 80

Rep: Reputation: 5
@Mark
Maybe I don't use it to its full extend, but I found Unison rather easy to set up. I found the wizard simple then after a set up I figured it is just a easier and faster to write my own prf files:
Quote:
>>>cat .unison/books.prf
label = Sync with xeon
root = /home/marst/books
root = ssh://marst@10.0.0.5//home/marst/books
sshargs = -p 2222
fat = true
 
Old 04-07-2013, 03:42 PM   #8
longus
Member
 
Registered: Dec 2008
Posts: 49

Original Poster
Rep: Reputation: 3
Actually it is quite simple to setup. I have tried it.

Well, one question remain. The usb stick must be mounted before starting the unison in XFCE, otherwise it cant fount the drive. I avoid the automounting in XFCE because it mounts my 3G modem as a storage drive.

One more question. Does slackware-14 mount this usb stick on the same location in /run directory every time?

Still searching something like daemon automatically starting the process of synchronization.
rsync can't offer an option to control, i.e. to choose which file in which direction to update.

Last edited by longus; 04-07-2013 at 03:47 PM.
 
Old 04-07-2013, 04:32 PM   #9
eloi
Member
 
Registered: Nov 2010
Posts: 227

Rep: Reputation: 61
Quote:
Originally Posted by mariostg View Post
@longus
Not sure if unison has daemon mode. I know it operates either from the console or GUI, advise you of potential conflicts and operate bidirectionally. rsync is good too but I don't think it helps in file conflict resolution and does not work bidirectionally.
I don't know what you mean by "conflict resolution".

About "bidirectionally" the only I can say is that the rsync options I've used above respect modification time. So running both commands rsync will copy newer versions in both directories. Then if modification time is your interest and assuming the other machines you plug the usb memory use the same time zone and clock settings that two commands should do the job.

Do not hesitate in telling me if I forget something. Four eyes see better than two .

Anyway, in general terms, if the flash drive will jump from some annoying OS to another worse I think, honestly, that sync *from* the flash drive is not advisable.

Last edited by eloi; 04-07-2013 at 05:27 PM. Reason: Added paragraph
 
Old 04-07-2013, 08:46 PM   #10
mariostg
Member
 
Registered: Apr 2011
Location: Gatineau, Quebec
Distribution: OpenBSD
Posts: 80

Rep: Reputation: 5
@eloi
Simply means that if per example a file has gone AWOL unison will not know "which whay" the synchronize should be. So it will be to the user to decide what to do i.e. skip or restore at the destination where missing.

Don't get me wrong, I use rsync if I want to move files in only one way, but I will use unison if I want to synchronize. It just makes me feel safer.

And I only rsync/unison between Linux boxes... I stay away from OS that gets into my way
 
Old 04-08-2013, 01:10 AM   #11
Mark Pettit
Member
 
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 15.0
Posts: 619

Rep: Reputation: 299Reputation: 299Reputation: 299
Conflict resolution : There are several ways in which Unison can break. We use Unison to transfer files between 4 companies, across Windows, Linux and Solaris. We love Unison and would be hard pressed to get by without it. But even so, it does trip up over some issues, which are not trivial to solve. I'll describe some - they may not apply in your case. But do note that technically Unison is a distributed file system, with (relatively) high latency between updates. (in comparison to say a mirrored SAN disk system).
Case 1) User on side (a) updates a file and at the same time a user on suide (b) updates the same file. As Unison is essentially master-master, it can't decide which is the real "latest" file and even if it chooses (which it doesn't), someone will be unhappy.
Case 2) Two files "aaa.txt" and "AAA.TXT" are created on Unix/Linux side and are synced to a single Windows machine - instant fail as Windows is case-insensitive.

Now, if you're using a "simple" setup to your own USB disk, then chances are that you'll be fine. But be aware that there's more to Unison than meets the eye.
 
Old 04-08-2013, 05:19 AM   #12
eloi
Member
 
Registered: Nov 2010
Posts: 227

Rep: Reputation: 61
Quote:
Originally Posted by mariostg View Post
@eloi
Simply means that if per example a file has gone AWOL unison will not know "which whay" the synchronize should be. So it will be to the user to decide what to do i.e. skip or restore at the destination where missing.
You're right. I've never though about bidirectional sync. Now I see that the option --delete is a problem.

I've found this:

http://superuser.com/questions/16631...omparing-files

You could run:

Code:
$ find /HDD/directory -printf "%P\n" | sort > /tmp/file1
$ find /media/memory/directory -printf "%P\n" | sort | diff - /tmp/file1
and manually remove from that list the files you don't want to keep before using rsync in both directions without the --delete option.

But there is one more problem I can't think of an easy, practical solution, the rare case of files with same name, time but different content.

Finally, I insist, even if you use it just on Linux boxes, rely on sync *from* a flash drive is not a good idea.

Last edited by eloi; 04-08-2013 at 05:45 AM.
 
  


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
HAL automount permissions differs between USB HD and USB memory stick Olaus Slackware 5 06-28-2010 06:34 PM
Two USB memory devies (stick memory/jump drive) one works one not Mark_in_Hollywood Linux - Hardware 5 05-20-2008 07:35 PM
*** USB external hard drive and USB memory stick linux_2007_ Linux - General 1 07-17-2007 04:20 PM
USB memory, Compact Flash, Memory Stick energiza Linux - Hardware 2 08-22-2006 09:29 PM
Missing memory in USB stick, flash memory, removable hd etc bamboo_spider Linux - Newbie 3 06-14-2006 05:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 11:34 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