You are not logged in.

#1 2011-03-26 01:36:39

JMO
Member
From: Argentina
Registered: 2006-04-08
Posts: 98

How do I backup to a specific device at an specific moment?

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

#2 2011-03-26 07:17:23

schivmeister
Developer/TU
From: Singapore
Registered: 2007-05-17
Posts: 971
Website

Re: How do I backup to a specific device at an specific moment?

JMO wrote:

Is it possible to use some kind of "device ID" to take a signal from udev and pipe it anywhere else?

Yes. The attributes.

JMO wrote:

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

#3 2011-03-26 07:32:47

TheSaint
Member
From: my computer
Registered: 2007-08-19
Posts: 1,523

Re: How do I backup to a specific device at an specific moment?

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 wink

Offline

#4 2011-03-26 09:54:48

ktemkin
Member
From: Binghamton
Registered: 2010-12-28
Posts: 6
Website

Re: How do I backup to a specific device at an specific moment?

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

#5 2011-03-26 13:49:34

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: How do I backup to a specific device at an specific moment?

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

#6 2011-03-26 16:20:21

TheSaint
Member
From: my computer
Registered: 2007-08-19
Posts: 1,523

Re: How do I backup to a specific device at an specific moment?

ktemkin wrote:

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 wink

Offline

#7 2011-03-28 02:14:51

JMO
Member
From: Argentina
Registered: 2006-04-08
Posts: 98

Re: How do I backup to a specific device at an specific moment?

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

Board footer

Powered by FluxBB