Linux - GeneralThis Linux 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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.
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.
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.
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:
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.
Here's a sample udev rule (/etc/udev/rules.d/90-local.rules) in case anyone wants to automate running a script on plugging in a USB HDD
Code:
# Hitachi SimpleDrive mini, model HTS545050B9A300 (500 GB USB HDD)
SUBSYSTEM=="block", ATTR{size}=="976768002", ATTRS{product}=="SimpleDrive mini", ATTRS{serial}=="2512009121920487", ACTION=="add", RUN+="/lib/udev/local.usb.hdd.sh add $devpath"
Notes:
Values used in ATTR{*}== and ATTRS{*}== can be found when the device is plugged in by running udevadm info -a -p /sys/block/sdc/sdc1, replacing sdc and sdc1 with appropriate values.
All the ATTRS{*}== values must be taken from a single parent device.
The called script can determine the /dev/sd* device file to use in mounting by
Code:
maj_min="$(cat "/sys$devpath/dev")"
buf="$(ls -l "/dev/block/$maj_min")"
dev_file="/dev/${buf##*/}"
mount $dev_file $mountpoint
When udev runs such a script it captures stdout (and stderr?). For debugging they can be redirected to somewhere visible.
Last edited by catkin; 03-14-2010 at 11:18 PM.
Reason: Added buf="$(ls -l "/dev/block/$maj_min")"
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.