LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-13-2010, 08:43 AM   #1
mr_minning
LQ Newbie
 
Registered: Dec 2008
Location: Gothenburg, Sweden
Distribution: Fedora 20, CentOS 7, Ubuntu
Posts: 19

Rep: Reputation: 10
Question Autobackup on portable USB HDD


I got a CentOS 5.3 fileserver machine (no monitor/kb/mouse).
I'd like to "pair" it with a specific USB drive, so that when this USB drive is connected and mounted it would start a backup - just a simple cp /source /target will do for now - it's the "autorun on mounted a specific USB drive" part I can't really solve.
Is there an elegant way to do this some sort of autorun? My only really rough idea to do it is to check if the USB drive is available with a script run in crontab every minute :-\

Cheers!
 
Old 10-13-2010, 01:23 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
There certainly is ...

udev-rules & script tied in.


Cheers,
Tink
 
Old 10-13-2010, 09:45 PM   #3
longbow0
LQ Newbie
 
Registered: Jul 2005
Distribution: Debian
Posts: 20

Rep: Reputation: 2
may be it is time to forget usb storage and use a cloud storage service, such as Dropbox.
 
Old 10-14-2010, 02:32 AM   #4
mr_minning
LQ Newbie
 
Registered: Dec 2008
Location: Gothenburg, Sweden
Distribution: Fedora 20, CentOS 7, Ubuntu
Posts: 19

Original Poster
Rep: Reputation: 10
Quote:
There certainly is ...

udev-rules & script tied in.
Thanks! This seems to be just what I want. I suppose I'll soon be good friends with dmesg and this doc http://www.reactivated.net/writing_udev_rules.html

Quote:
may be it is time to forget usb storage and use a cloud storage service, such as Dropbox.
The cloud... Well, in this case I want to backup photos (about 15GB so far, and rapidly growing), and I honestly don't trust the cloud as a source of backup. I'd rather go the "backup buddy"-way, than the cloud in this case to be honest.

Last edited by mr_minning; 10-14-2010 at 02:35 AM.
 
Old 10-14-2010, 02:34 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by mr_minning View Post
Thanks! This seems to be just what I want. I suppose I'll soon be good friends with dmesg and this doc http://www.reactivated.net/writing_udev_rules.html
Yeah - good read; slightly dated, I'm afraid. udevinfo isn't
around any more. But a google for udevadm & serial should get
you on the right track. If I still had the command in roots
bash_history I would have posted it - but I don't ;}


Cheers,
Tink
 
Old 10-24-2010, 05:02 AM   #6
mr_minning
LQ Newbie
 
Registered: Dec 2008
Location: Gothenburg, Sweden
Distribution: Fedora 20, CentOS 7, Ubuntu
Posts: 19

Original Poster
Rep: Reputation: 10
I have some trouble getting this to work. My target machine has CentOS 5.4, but it doesn't have the udevadm command. So I tried to do the developing on a Fedora 13 laptop.
I thought that it would be nice not to change any mountpoints or such. Gnome always mounts the USB disk as /media/BackupDisk anyway. So I created a /etc/udev/rules.d/98-local.rules (I've tried to name it 10-local.rules too) that looks like this:
KERNEL=="sd?1", SUBSYSTEMS=="scsi", ATTRS{"serial"}=="00E0010575A18", RUN+="/etc/udev/backup"

I've tried some variants of above too (like)
DRIVERS=="usb", SUBSYSTEMS=="usb", ATTRS{"serial"}=="00E0010575A18", RUN+="/etc/udev/backup"

After each change I ran:
udevadm control --reload-rules
The unplugged the usb cord, waited a few sec, and then replugged it.

The file /etc/udev/backup (permission 755) has been reduced to a bare minimum to se if it runs (which it doesn't):
#!/bin/bash
touch /tmp/zzzz

Still nothing How do I go about debuging this? Or is there an obvious blooper above?

Cheers,
 
Old 10-27-2010, 02:52 PM   #7
mr_minning
LQ Newbie
 
Registered: Dec 2008
Location: Gothenburg, Sweden
Distribution: Fedora 20, CentOS 7, Ubuntu
Posts: 19

Original Poster
Rep: Reputation: 10
Red face

Quote:
Originally Posted by mr_minning View Post
KERNEL=="sd?1", SUBSYSTEMS=="scsi", ATTRS{"serial"}=="00E0010575A18", RUN+="/etc/udev/backup"
I found my mistake. It's supposed to be ATTRS{serial} w/o quotationmarks. I also removed the KERNEL bit and changed SUBSYSTEMS to "usb". Just to keep it in the same hierarchy level. Dunno if it makes a difference, but it works now.

BR,
mr_minning
 
Old 10-27-2010, 04:52 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Well done, and thanks for sharing your findings with the community.


Cheers,
Tink
 
  


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
Portable HDD - Windows and Linux osaddict Linux - Newbie 7 09-02-2010 03:33 PM
Best portable HDD brand? SentralOrigin General 7 11-30-2008 07:09 PM
need a portable linux distro to bring on portable usb hard drive... pippo17 Linux - Distributions 3 10-20-2008 07:41 AM
how to do a dual boot (Windows on portable HDD) linux on computer HDD izquierdista Linux - General 5 01-28-2006 10:50 AM
Portable WIn32 hdd rottmanj Linux - Hardware 5 07-21-2003 09:05 AM


All times are GMT -5. The time now is 06:54 AM.

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