LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux > Linux - General
User Name
Password
Linux - General This forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Tags used in this thread
Popular LQ Tags , , , ,

Reply
 
Thread Tools
Old 01-25-2007, 11:28 PM   #1
Valandil
LQ Newbie
 
Registered: Jan 2007
Location: Quebec, Canada
Distribution: Mandriva One 2007
Posts: 6
Thanked: 0
Sync a USB flash drive with HD folders, possible?


[Log in to get rid of this advertisement]
Hello there!

I would like to know if there is a way to tell my distro (Mandriva One 2007) that I want my USB stick to synchronize a certain folder it contains with a certain folder my HD contains. By synchronizing, I mean that I want files, for instance on the USB stick, that have been edited more recently that those on the HD replace the one existing on the HD. I guess it is possible with Cron, but since I am a not yet a pro with the shell commands, I need some help out there.

If you need more clarity, just tell me.

Thanks in advance!

P.-S. By the way, I hope my English is not too bad, I'm from Quebec, the last fortress of French in Canada, meh.
Valandil is offline  
Tag This Post , , , ,
Reply With Quote
Old 01-26-2007, 02:12 AM   #2
dv502
Member
 
Registered: Sep 2006
Location: New York City
Distribution: Arch Linux
Posts: 506
Thanked: 12
You can use the rsync command to synchronize folders.

rsync -a source --delete destination

The source and destination represents the paths to your folders.

An example:

rsync -a /mnt/sda1/ --delete /home/user/some_dir

-a will archive all folders and subdirectories
--delete will synchronize folders

The /mnt/sda1 is a usb stick, it will have the recent updated files. Rsync will make a duplicate copy of
/mnt/sda1 to /home/user/some_dir

Use the --delete with caution! This will delete files
from the destination path not found in the source path.

In other words, files updated or deleted from the source will be applied equally to the destination.

Practice first.

You can do the same thing without the --delete option. This will keep the files on both sides updated, but nothing is deleted.

Last edited by dv502; 01-26-2007 at 02:25 AM..
dv502 is offline     Reply With Quote
Old 01-26-2007, 08:11 AM   #3
Valandil
LQ Newbie
 
Registered: Jan 2007
Location: Quebec, Canada
Distribution: Mandriva One 2007
Posts: 6
Thanked: 0

Original Poster
Thanks a bunch. I still have one more question, though. Can I have Cron do this each time I plug in the USB stick?
Valandil is offline     Reply With Quote
Old 01-26-2007, 10:57 AM   #4
dv502
Member
 
Registered: Sep 2006
Location: New York City
Distribution: Arch Linux
Posts: 506
Thanked: 12
No. Cron does not detect nor mount devices. Cron is a schedular program. You can use cron to schedule
tasks at specific times. You can use cron to do
synchronizing of your usb stick and folder at certain
time schedules. Just make sure the usb stick is mounted before cron runs its schedule time.

Do a google search on linux cron setup or how to.

Hope it works

Last edited by dv502; 01-26-2007 at 11:18 AM..
dv502 is offline     Reply With Quote
Old 01-27-2007, 04:26 PM   #5
Valandil
LQ Newbie
 
Registered: Jan 2007
Location: Quebec, Canada
Distribution: Mandriva One 2007
Posts: 6
Thanked: 0

Original Poster
Thanks guys!

I fould something that would permit me to do what I want. There are udev rules that makesa backup of all the data on a USB stick to the HD, it seems. I can meld the rsync feature with this so it will do it automatically.

See ya!
Valandil is offline     Reply With Quote
Old 09-21-2007, 09:00 PM   #6
scribe777
LQ Newbie
 
Registered: Sep 2007
Posts: 1
Thanked: 0
Correct Options: "sync preferring newest"

Hey guys. I came to this thread seeking the same advice: How to SYNC USB drive folder with system drive folder, always preferring newest files. After playing with rsync, -av will not SYNC preferring newest. It will always overwrite dest files with source files-- even if dest files are newer. The two commands I run to SYNC two folders preferring newest are:

rsync -avuz source/ dest/
rsync -avuz dest/ source/


This will assure both folders are in sync with latest files always being used.

NOTE: the trailing '/' is also important!

'avuz' sounds like something. I guess you could also remember 'zuva'

Hope this helps.
scribe777 is offline     Reply With Quote
Old 02-24-2009, 05:55 AM   #7
welle
LQ Newbie
 
Registered: Jan 2005
Location: Germany
Distribution: SuSE Linux 9.2
Posts: 3
Thanked: 0
usbsync

There is a nicely convenient tool called usbsync which has specially been desgined for the purpose of keeping a usb flash drive in sync with multiple Unix hosts.

Check it out at http://klingspor-thueringen.de/usbsync

Cheers,
welle
welle is offline     Reply With Quote
Old 02-24-2009, 02:01 PM   #8
dv502
Member
 
Registered: Sep 2006
Location: New York City
Distribution: Arch Linux
Posts: 506
Thanked: 12
The post is more than two years old...
dv502 is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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
USB Pen Drive / Flash Drive Unmounted but the power is there teluguswan Linux - Hardware 11 10-04-2008 04:36 PM
USB flash drive (Pen drive) mounts read only prabhatsoni Linux - Hardware 24 07-02-2007 02:28 PM
Using a usb thumb drive or flash drive as a swap partition. stevenjoseph Linux - Hardware 2 06-09-2006 10:56 AM
Mount an USB-Drive sync ToK Ubuntu 4 03-08-2006 04:14 AM
Usb drive file sync pembo13 Linux - General 2 11-11-2004 10:56 PM


All times are GMT -5. The time now is 03:31 AM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration