Drive backup Images


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Drive backup Images
# 1  
Old 03-01-2008
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
# 2  
Old 03-01-2008
Drive backup Images

Every year I update and tweak my scripts, here is my latest...
It takes about 2-1/2 hrs to disk image my 250gb drive Smilie

HTML Code:
#! /bin/bash
#
# OS:      Unix/Linux 
# Name:    hda-to-hdc
# Ver:     03/01/08 
# Purpose: Full disk image copy
# By:      Jan Zumwalt - www.neatinfo.com   
#
# 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
            # Here we go!!!
            
         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

Last edited by jwzumwalt; 03-01-2008 at 01:53 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash Script to find/sort/move images/duplicate images from USB drive

Ultimately, I'm looking to create a script that allows me to plug in a usb drive with lots of jpegs on it & copy them over to a folder on my hard drive. So in the process of copying I am looking to hash check them, record dupes to a file, copy only 1 of the identical files (if it doesn't exsist... (1 Reply)
Discussion started by: JonaQuinn
1 Replies

2. Solaris

possible to do ufsdump backup without a tape drive ?

hi friends, i am trying to patch a solaris 9 server. However i need to do a ufsdump backup before any patching. There is no hardware port for connecting the tape drive. Any other ways to do a ufsdump ? :wall: (2 Replies)
Discussion started by: Exposure
2 Replies

3. Solaris

Backup to remote tape drive

Hello all, I'm trying to backup some files on a solaris 10 machine to the remote tape drive connected to another solaris 10 machine. I have set up rsh to allow for password-less connection between the servers, but I'm not able to write to the tape with the command: root@sdp4a>tar cvf... (1 Reply)
Discussion started by: kerrygold
1 Replies

4. Filesystems, Disks and Memory

Backup to NTFS Drive?

Just some info about my hard drive setup. I have a 150GB WD Raptor X as my boot drive with partitions for Ubuntu and Windows. I have 500GB hard drive for my home partition (mainly to keep my movie and music collections since the Raptor is too small) and I also have an external 500GB hard drive... (0 Replies)
Discussion started by: pyroguysf
0 Replies

5. HP-UX

tape drive access/backup

Need assistance: Have HP Visualize C3600 workstation, HP-UX 10.20, and HP C6364A 12GB DDS-3 SCSI DAT drive. I am not a UNIX programmer and did not configure/build workstation. Ran ioscan and shows up as HPC1537A, class tape, and 10/0/15/0.2.0. Switch on back of unit is denoted SCSI ID and is... (5 Replies)
Discussion started by: davel1000
5 Replies

6. UNIX for Dummies Questions & Answers

How to view and recognize a backup drive

on Darwin terminal how do i do it? (0 Replies)
Discussion started by: cleansing_flame
0 Replies

7. AIX

AIX Tape Drive Backup

Currently I have a Dell Ultrium LTO 2 Tape Drive. I am going to have a IBM AIX server. Just wonder if it is possibe to connect this tape drive to the aix server? I have Brightstor Arcserver installed on another win 2003 server. Is it possible to install the arcserve agent on the aix and use the... (1 Reply)
Discussion started by: ming413
1 Replies

8. UNIX for Dummies Questions & Answers

Replace the tape backup drive

Please help me!!!. I am new to Unix and I have to replace the tape backup drive. Originally the system had an IBM tape drive (Rhomat) that is damged. I changed it and installed a dat drive HP 5000+. The hardware recognize the drive, the diagnostics if OK. But when I try to install the operating... (3 Replies)
Discussion started by: allaite2
3 Replies

9. Cybersecurity

Unix backup to tape drive

does anyone know how I can make an automatic backup of files to a tape drive under UNIX. I have so many commands, I don't know which goes where. I have commands for the task scheduler, Cron and other unix commands. Please help. Very Urgent. Thanks (3 Replies)
Discussion started by: Cute
3 Replies
Login or Register to Ask a Question