About once a year I update my scripts and make little tweeks. This is my latest...
#! /bin/bash
#
# OS: Unix/Linux
# Name: hda-to-hdc
# Ver: 03/01/08
# Purpose: Full disk image copy
# By: Jan Zumwalt - www.neatinfo.com - root directory list
#
# REMARKS:
# I use the fllowing echo commands that some may not be
# familure with...
#
# -e = enable interpretation of backslash codes
# -n = disable newline at end of line (i.e. user input prompt)
# \t = tab
#
# This program uses (and offers to create) $HOME/logs/backup.log
# The dd command is used; where "if" stands for "in file"
# and "of" is the "out file". Therefore "if" is the source
# drive and "of" is the target drive.
#
# The source and target are designated by hda, hdb, hdc, hdd, etc.
# hda thru hdd are the four drives that may be connected to the
# computers IDE cables. Numbers behind these designations are the
# partitions. So, hda1 is the first drive and the first partition.
# hdb3 would be the second drive and the third partition.
#
# This program can also be used for other drives and cables such
# as SCSI or SATA. It has been several years since I used it for
# these and so I did not risk giving an example that may be
# outdated or have an error.
while :
do
echo ; echo ; echo
echo -e "\t Drive Image Copy"
echo -e "\t By: Jan Zumwalt"
echo -e "\t Ver 03/01/08\n"
echo -e "\tThis program copies the entire disk image "
echo -e "\tfrom [hda] to the [hdc] drive. (hda --> hdc)"
echo
echo -en "\tIs this what you want to do? [y/n/q] "
read ANSWER
case $ANSWER in
[Yy]|[Yy][Ee][Ss])
echo
echo -e "\tOK! Here we go..."
# see if log directory exist
if [ ! -d $HOME/logs ]; then
echo -e "\n\n\t\t*** Log directory not found ***"
echo -en "\n\tShould I create the directory I need for logs (\$Home/logs)? "
read ANSWER2
case $ANSWER2 in
[Yy]|[Yy][Ee][Ss])
mkdir $HOME/logs
esac
fi
# opertunity to add comment to log file
echo -e "\n\tYou may now add a comment for the log file..."
echo -en "\t"
read ANSWER
echo -e "\t"$ANSWER >> $HOME/logs/backup.log
# save backup starting time
echo -en "\tBackup start time = " `date`
echo -e "\tBackup start time = " `date` >> $HOME/logs/backup.log
# The actual backup is done here. Included are some possible options.
# These options are machine specific - here are mine...
# dd if=/dev/hda1 of=/dev/hdc1 # image win partition
# dd if=/dev/hda7 of=/dev/hdc7 # image linux partition
dd if=/dev/hda of=/dev/hdc bs=1024k
# save backup ending time
echo -e "\n\tBackup end time = " `date`"\n"
echo -e "\tBackup end time = " `date` >> $HOME/logs/backup.log
# success - show log file and exit
echo -e "\tScript completed succesfully.\n"
echo -e "\t*******************************************"
echo -e "\t*** Here is a copy of your log file ***"
echo -e "\t*******************************************"
cat $HOME/logs/backup.log
echo -en "\n\tPress the [ENTER] key to exit."
read ANSWER
exit 0;;
# we are here because the user said not to run
[Nn]|[Nn][Oo]|[Qq]|[Qq]][Uu][Ii][Tt])
echo -e "\tOK! I am quiting..."
echo -en "\tPress the [ENTER] key to exit."
read ANSWER
exit 1;;
# the users response does not make sense so...
*) echo
echo -e "\tPlease answer with y/n/q "
echo -en "\tPress the [ENTER] key to try again..."
read ANSWER
clear ;;
esac
done
exit 1