Skip to end of metadata
Go to start of metadata

Automation of backups copy

What do you mean with 'automation of backups copy' ?

Here 'automation' is to be understood that way: the goal is to make the backups of a service being copied on the BlueLight external hard disk as soon as the hard disk is plugged into the service's machine. Once the copying is done, or if something goes wrong, a mail is sent out to 'bluelight@auroville.org.in' for information.

How can I do that ?

We will use the power of Udev : Udev Rules, which allows to run a program (which can be a script) on attachment of a given device.
Then we will need a script which will take care of doing all the copying tasks (mounting partitions, mounting the external hard disk, copying the files, unmounting the hard disk, unmounting the previously mounted partitions, and sending an email to inform BlueLight of the result of the process).

Where can I find the udev rule ?

The udev rule

Here it is :

/etc/udev/rules.d/95-locales.rules

WARNING: That rule will trigger the script only when the BlueLight's Maxtor external hard disk is plugged in,
since the serial match. For trigger on an other device, you have to change the serial to match the one of the device.

But wait - How can I write my own ?

A nice howto can be found there : http://reactivated.net/writing_udev_rules.html
Yet, udev has changed. To get the infos about the device /dev/sde for instance, you should now run:

Where can I find the script ?

Actually, there are two scripts:
One script "autopulld" which will load the script in the background. This script is called by Udev when the HD is plugged in.
This kind of script is refered to as a 'daemonizer'.
The main script "autopull", making all the operations

Here is the daemonizer:

/home/bl/scripts/autopulld

Here is the main script:

/home/bl/scripts/autopull

Get these two scripts where they belong ('/home/bl/scripts/') and make them executable.
If you store them in a different place, you will have to edit the content of 'autopulld' to use the correct path to 'autopull', and you will have to edit the udev rule to point to the correct path for 'autopulld'.

Remember, you will get an email only if postfix is set up and mailx as well.