The UNIX and Linux Forums  


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




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 01-03-2009
cfajohnson's Avatar
cfajohnson cfajohnson is online now Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,369
Quote:
Originally Posted by jwzumwalt View Post
I do a complete drive copy of my 250gb drive in about 2-1/2hrs with this program.

I can do a full backup of my 250GB drive (about 230GB occupied) in about 2-1/4hrs with this command:


Code:
tar czf music.tgz /public/music

It has the advantage over your script in that it doesn't require an second identically sized partition to copy it to.

Another advantage is that it will use less space than using dd.
Quote:
Feel free to offer suggestions
brain@removed by reborg


Code:
#! /bin/bash 
# name: drive-image.sh, disk image copy script
# by:   Jan Zumwalt - www.neatinfo.com 
# ver:  01/01/09
# remarks:
# -e = enable interpretation of backslash codes
# -n = disable newline at end of line (i.e. user input prompt)

IMAGE_FROM=hda  # the drive or partition we will copy (save). 
IMAGE_TO=hdc    # the target (were it will be saved)

I find it very strange that you hard-code the partitions in an interactive script.
Quote:
# Pretty ANSI writing

OFF="\033[0m"


Code:
OFF=$'\e[0m'

Quote:
BOLD="\033[1m"
DIM="\033[2m"
YELLOW="\033[1;33m"

The yellow text is illegible in my terminal windows.
Quote:
while :
do
clear
echo -en "\n"

Bizarre!

Why do you suppress the newline and then add one?

What's wrong with a simple echo?


Code:
echo

Quote:
echo -en "\t\t\t$BOLD Drive Image Copy\n"
echo -en "\t\t\t by:Jan Zumwalt\n"
echo -en "\t\t\t$YELLOW NeatInfo.com - Ver 01/01/09$OFF\n\n"
echo -en ".----------------- Here is your mounted media -----------------.\n"
echo -en ". .\n"
df[/code]

Why bother displaying all the partitions when you don't offer the user a way to select any of them?
Quote:
Code:
####snip####
read ANSWER
   case $ANSWER in 
      [1])

You don't need the brackets.

Code:
   case $ANSWER in 
      1)

And you don't need to redirect every line. Either use printf:

Code:
 
           printf "%s\n" \
              "[Desktop Entry]"                 \
              "Comment="                        \
       #### snip ####
              "X-KDE-SubstituteUID=false"       \
              "X-KDE-Username="                 > "dr-image.desktop"
           chmod  ugo+x "dr-image.desktop" # make shortcut executable

Or braces:


Code:
           {
           echo "[Desktop Entry]"
           echo "Comment="
           echo "Comment[en_US]="
       #### snip ####
           echo "X-KDE-SubstituteUID=false"
           echo "X-KDE-Username="
           }  > "dr-image.desktop"