The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
tape drive access/backup davel1000 HP-UX 5 05-15-2008 10:16 AM
What's the right filesystem for your portable backup drive? iBot UNIX and Linux RSS News 0 04-16-2008 03:40 PM
AIX Tape Drive Backup ming413 AIX 1 08-14-2007 04:46 PM
Replace the tape backup drive allaite2 UNIX for Dummies Questions & Answers 3 06-05-2002 12:29 AM
Unix backup to tape drive Cute Security 3 12-21-2001 10:34 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-01-2008
jwzumwalt jwzumwalt is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 15
Disk / Partition image script

About once a year I update my scripts and make little tweeks. This is my latest...

HTML Code:
#! /bin/bash
#
# OS:      Unix/Linux 
# Name:    hda-to-hdc
# Ver:     03/01/08 
# Purpose: Full disk image copy
# By:      Jan Zumwalt - [url=http://www.neatinfo.com]www.neatinfo.com - root directory list[/url]   
#
# 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
 

Bookmarks

Tags
linux commands

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:02 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0