2007
02.25


The scripts that I create for my everyday use are not as complex as the one previously posted by cperdana on automaticly changing desktop’s background. They are mostly straight forward; a sequence of commands and some variables, if there are any, and written by a shell programmer wannabe with a manual and some simple ideas.

As the theme of this post is Yomud’s crashing hard drive, I’ll just share the simple script I use to backup the important stuff in my laptop.

#!/bin/bash

HOMES="shakir svn"
MOUNT=/mnt/backup_temp
TARGET_DIR=/backup

sudo mkdir $MOUNT

# Mount my 200GB external harddisk
sudo mount -t reiserfs /dev/`cat /proc/partitions | grep 199141708 | awk ‘{ print $4 }’` $MOUNT

echo "### Backing up /etc"
cd /
sudo tar czf $MOUNT$TARGET_DIR/`date +%F`-etc.tar.gz etc

echo "### Backing up MySQL databases"
sudo /etc/init.d/mysql start
mysqldump -u root mysql > $MOUNT$TARGET_DIR/`date +%F`-sqldump.sql
sudo /etc/init.d/mysql stop

echo "### Backing up home directories"
cd /home
time sudo tar czf $MOUNT$TARGET_DIR/`date +%F`-home.tar.gz $HOMES

echo "### Backup completed at `date`"

sudo umount $MOUNT
sudo rmdir $MOUNT

It doesn’t have fancy features such as incremental backup whatsoever, but it gets the job done for me. The important thing is to have backups of our years of work’s worth since who knows for sure when will our hard drives fail?

3 comments so far

Add Your Comment
  1. aha, nice. anyway,i’m switching to vista right now.hahaaha!!!!.w0w.

  2. Vista sure already have a very user friendly backup program that can do wonders for you, hahaha

  3. berapa lama tahan dengan vista tu hehe