D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

[LUG] Help: Script to backup /home to DVD



After some googling I've managed to produce the
following script to backup my home directory to DVD.

#!/bin/bash

# Simple DVD backup of /home/user directory.
# Method: Tar /home/user directory and store
# in /tmp/backup/keithshome as a dated file.
# Write to DVD using growisofs
#
# SuSE 9.0 Distro
#

DATE=$(date +%d-%m-%Y)

# My home directory
SOURCE="/home/keith"

# Backup directory and dated backup file
BACKUP_DIR="/tmp/backup/keithhome/"
BACKUP_FILE=$BACKUP_DIR"backup-"$DATE".tar"

# Remove old backup directory and create a new one
rm -rf $BACKUP_DIR
mkdir $BACKUP_DIR

# Tar SOURCE and store it in BACKUP_FILE
echo Backing up $SOURCE to file $BACKUP
/bin/tar -cpf $BACKUP_FILE $SOURCE

# Erase old DVD disk
echo Erasing DVD in preparation for backup
/usr/local/bin/dvd+rw-format -force /media/dvdrecorder

# Burn
echo Burning backup
growisofs -dvd-compat -Z /media/dvdrecorder -r $BACKUP_FILE

# Show we've finished
echo Finished backup
exit 0

It's my first attempt at writing a script so I'm
somewhat apprehensive. Would some knowledgable, kind
person run their eye over it and point out my errors?
In particular I'm not sure about my method of
storing and dating the tar file.

Keith

--
A Linux System
SuSE 9.0 on ECS KS5A/XP with 1.2GHz Athlon, 384MB RAM, 20GB Maxtor HD
and using Mozilla-Thunderbird

--
The Mailing List for the Devon & Cornwall LUG
Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the
message body to unsubscribe.



Lynx friendly