You are not logged in.
Here is what I want to do:
- Any night of any day in the week, connect my external HDD to my Arch computer, and go to sleep.
- At the next morning there is a backup done on that HDD.
I understand the basics on some tools which can help me do that (crond, dd, udisks), but I utterly uncapable to make it work all together, so let me ask some questions to start looking myself:
- Is it possible to use some kind of "device ID" to take a signal from udev and pipe it anywhere else?
- Which daemon could be watching in order to take that signal and execute the backup script?
Thanks for patience =P
Last edited by JMO (2011-03-26 14:56:52)
Offline
Is it possible to use some kind of "device ID" to take a signal from udev and pipe it anywhere else?
Yes. The attributes.
Which daemon could be watching in order to take that signal and execute the backup script?
Udev. The rules.
For time-specific actions you will need cron.
I need real, proper pen and paper for this.
Offline
I just got this idea, using udev script to start a backup.
When you plug in the media it will record and it could wait a specific moment to start the backup procedure. According to the script and cron matters
do it good first, it will be faster than do it twice the saint
Offline
Since it's happening so infrequently (once every 24 hours), why not just set up a simple script to run every night at a time you're usually asleep?
Here are some tools you'll probably find helpful:
1) Cron: runs a specific task at set times. Arch Wiki: Cron
(If midnight works for you, you can simply place your script in /etc/cron.daily/; it will then run each night when the clock strikes 12.)
2) rsync: copies files incrementally (i.e. only files that have changed will be copied) Arch Wiki: Rsync
In your script, you can pretty easily check to see if the drive is plugged in using its label; there's a nice set of symlinks in /dev/disk/by-label. This short script runs one or more commands if and only if a block device is attached with label yourDiskLabel.
#!/bin/bash
if [ -b /dev/disk/by-label/yourDiskLabel ]
then
#perform your backup command(s)
fi
(If, for some reason, you have multiple drives with the same label, you can use their UUID/universally unique identifier. There are a similar set of symlinks in /dev/disk/by-uuid.
---
just got this idea, using udev script to start a backup.
When you plug in the media it will record and it could wait a specific moment to start the backup procedure.
I would think this would just take up more resources than just checking for the drive's presence at a set time.
Offline
Note that if you're planning to use dd, your source partition should be unmounted; otherwise your backup will probably be corrupt (yes, I did that. At work.)
If copying files (with rsync, cp, whatever), it should be safer but it's probably not a good idea to do it on a "moving" partition either (files can change while you're copying them...) Personnaly I use LVM to create a snapshot before backuping.
Offline
I would think this would just take up more resources than just checking for the drive's presence at a set time.
I think that udev will only put a flag, and the program will look for that.
Even look into /proc/partitions may give some clue, but to be more sure I think there should be a more specific partition details somewhere.
do it good first, it will be faster than do it twice the saint
Offline
Ok ok. I'm reading about udev rules and the wiki. Specifically, I want to start the backup script when the external HDD device node is created, wich doesnt seem that complicated after your explanations. I'll bring any news as soon I got them. Thanks!
Offline