Backup to avoid the worst

Since I bought my external Lacie HD, I must have backed up my data only once, just before shrinking a partition (quite a delicate operation) on my main computer. Then I realised some days ago that if something really bad happens on this computer (which is going on its 3 years old), I would lost all my photos, music, websites development files, documents, etc. To avoid that catastrophic situation and force me to backup data, I wrote a shell script automatically executed everyday by cron.

Of course, running the script everyday without the Lacie HD switched on wouldn’t be very useful. That’s why I used the “xmessage” command to warn me that I shall switch the drive on and retry the script or quit. Everything is performed by the script and adding the following line to “/etc/crontab” will make the script to be run everyday at 20:00 sharp:

00 20 * * * harck export DISPLAY=:0 && /home/harck/scripts/backAll.sh

The “export DISPLAY=:0 &&” stuff is necessary for xmessage to work. A copy of the script is available here (simply rename it into *.sh and chmod it to 755).

Comments are closed.