LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Automatic harddisk to DVDbackup ;) Can someone take over this project? (http://www.linuxquestions.org/questions/programming-9/automatic-harddisk-to-dvdbackup-%3B-can-someone-take-over-this-project-703499/)

frenchn00b 02-09-2009 10:20 PM

Automatic harddisk to DVDbackup ;) Can someone take over this project?
 
New Automatic harddisk to DVDbackup
Lack of time, so Can someone take over this project?

It features that you can even burn with knoppix on read-only drives, since you tell him where to use the temp and you can later on have lot of txt files of the content of your dvd's that arent still in that diskdir format:http://ghisler.fileburst.com/plugins...irextended.zip


Code:

#!/bin/sh

echo " "
echo "Beware, this is very buggy program, no warranty, possible loss of data!"
echo "version 0.01 Frenchn00b, 3 Nov 2008 on Debian Etch"
if [ "$1" == "--help" ]  ; then
        echo "Use:"
        echo "    burnthefolder arg1 [arg2] [arg3] [arg4]"
        echo " "
        echo "Arg1:"
        echo "--debug"
        echo "--help        this help"
        echo "arg1        specify the device to burn eg /dev/hdc "
        echo " "
        echo "Arg2:"
        echo "--burn        to start burning with growisofs"
        echo "--simulate        to simulate burning"
        echo "Arg3:"
        echo "--noeject        Do not eject the media after burning"
        echo "--nosound        Do not start any sounds after burning"
echo "Arg3 Arg4:"
echo "  Arg3        --temp"

echo "  Arg4        folder where the temp files are generated eg /tmp/frenchn00b  and not /tmp/frenchn00b/  "

        exit 0
fi

if [ "$3" == "--temp" ] ; then
        TMPFILLOC="$4"
        if [ "$4" == "" ] ; then
                TMPFILLOC="/tmp"
        fi       
        else
        TMPFILLOC="/tmp"
fi

maxsizeofyourdevice=4294967296
echo "Maxsizeofyourdevice set to 4294967296"
SIZE=0
LISTTMP=""
LISTTMPH=""
TOTAL_SIZE=0
TO_BURN=""
CDROM="0"


 
if  [ "$CDROM" == "0" ] ; then
    ISO=`mktemp $TMPFILLOC/isoXXX`
    ISOH=`mktemp $TMPFILLOC/isoXXX`
    echo " "
    echo "temp files: $ISO $ISOH generated"
    LISTTMP="$LISTTMP $ISO "
    LISTTMPH="$LISTTMPH $ISOH "
    CDROM="1"
fi


for X in *
do
  SIZEH=`du -h "$X" | tail -n 1 | cut -f 1`
  SIZE=`du -b "$X" | tail -n 1 | cut -f 1`
 


  if [  `expr $SIZE + $TOTAL_SIZE` -gt "$maxsizeofyourdevice" ]
then
CDROM="0"
if  [ "$CDROM" == "0" ] ; then
    ISO=`mktemp $TMPFILLOC/isoXXX`
    ISOH=`mktemp $TMPFILLOC/isoXXX`
    echo " "
    echo "temp files: $ISO $ISOH generated"
    LISTTMP="$LISTTMP $ISO "
    LISTTMPH="$LISTTMPH $ISOH "
    CDROM="1"
fi

    TO_BURN="$(pwd)/$X"
    TOTAL_SIZE="$SIZE"
    if [ "$1" == "--debug" ]  ; then
            echo "1:$SIZEH/${TOTAL_SIZE}: $TO_BURN"
    else
            echo "1:$SIZE/${TOTAL_SIZE}/$maxsizeofyourdevice: $TO_BURN"
    fi
    echo "$SIZEH: $TO_BURN"  > "$ISOH"
    echo "$TO_BURN"  > "$ISO"
    CDROM="0"

  else
    TO_BURN="$(pwd)/$X"
    TO_BURNTOTAL="$TO_BURN $X "
    TOTAL_SIZE=`expr $SIZE + $TOTAL_SIZE`
    if [ "$1" == "--debug" ]  ; then
            echo "2:$SIZEH/${TOTAL_SIZE}: $TO_BURN"
    else
            echo "2:$SIZE/${TOTAL_SIZE}/$maxsizeofyourdevice: $TO_BURN"
    fi
    echo "$SIZEH: $TO_BURN"  >> "$ISOH"
    echo "$TO_BURN"  >> "$ISO"

  fi
       
done

#echo "DONE"
 
if [ "$1" == "--debug" ]  ; then
        echo " "
        echo "------------"
        echo "DEBUG Mode:"
        echo "$LISTTMP"
        for each in $LISTTMP ; do
                echo "$each:"
                cat "$each"
        done
fi

if [ "$1" == "--debug" ]  ; then
        echo " "
        echo "------------"
        echo "DEBUG Mode (human):"
        echo "$LISTTMPH"
        for each in $LISTTMPH ; do
                echo "$each:"
                cat "$each"
        done
fi

if [ ! "$1" == "--debug" ]  ; then

if [ "$2" == "--simulate" ]  ; then
        echo " "
        echo "------------"
        echo "Simulation type on $1 media, no burning of $LISTTMP"
        for each in $LISTTMP ; do
                echo "growisofs -Z $1 -R -J -path-file $each"
                echo "$each:"
                cat "$each"
        done
fi

if [ "$2" == "--burn" ]  ; then
        cdburncounter=1
        # echo $cdburncountermax cdburncounter
        cdburncountermax="`ls -1 $4 | while read n ; do  let counter+=1 ; clear ; echo $counter ;  done  `" ; echo $cdburncountermax
        echo " "
        echo "------------"
        echo "Burn on $1 media, no burning of $LISTTMP"
        for each in $LISTTMP ; do
        echo " "
        echo "------------"
                echo "nonhuman iso list: $LISTTMP "
                echo "human iso list: $LISTTMPH "
                echo "  "

                SIZEFR=0
                cat $each | while read fi ; do    incr=` du -b "$fi" |tail -n 1 | cut -f 1 ` ; let SIZEFR+=$incr ; echo "$SIZEFR" > "$4/filesz" ;  done
                printf "The final size of the archive is "
                printf `cat $4/filesz`
                sizelof=`cat $4/filesz`
## here pleazse below help, dont know how to calc
##                THEVQLUEFINQL1=`echo  $maxsizeofyourdevice - $sizelof  | bc `
##                THEVQLUEFINQL2=`echo  THEVQLUEFINQL1 /  $maxsizeofyourdevice * 100 ) | bc `
                echo " of $maxsizeofyourdevice ie  $THEVQLUEFINQL2"
                questionapp="checkcd"
                while [  "$questionapp" == "checkcd" ] ||  [  "$questionapp" == "listiso" ]  ||  [  "$questionapp" == "listisoless" ]  ||  [  "$questionapp" == "ejectin" ]  ||  [  "$questionapp" == "ejectout" ]  ||  [  "$questionapp" == "umountcd" ]  ; do
                        echo " "
                        echo "- if you would like to append the $each on dvd instead of create new media, type append followed by enter"
                        echo "- if you would like to skip $each on dvd instead of create new media, type skip followed by enter"
                        echo "- if you would like to listiso or listisoless to list the iso $each"
                        echo "- if you would like to checkcd to ls cdrom"
                        echo "- ejectin to slot in the cdrom"
                        echo "- umountcd to umount the cdrom"
                        echo "- ejectout to eject the cdrom"
                        echo "- Enter to continue for new DVD disc to be burnt"
                        printf "CD$cdburncounter/:>"
                        read questionapp
                        if [  "$questionapp" == "checkcd" ]  ; then
                                echo "Cdrom: $1"
                                mount "$1" `cat /etc/fstab | grep /dev/hdb  | awk ' { print $2 }  '`
                                ls  `cat /etc/fstab | grep $1  | awk ' { print $2 }  '`
                                umount `cat /etc/fstab | grep $1  | awk ' { print $2 }  '`
                        fi
 
                        if [  "$questionapp" == "listiso" ]  ; then
                                cat "$each"
                        fi
                        if [  "$questionapp" == "ejectin" ]  ; then
                                eject -t "$1"
                        fi
                        if [  "$questionapp" == "ejectout" ]  ; then
                                eject  "$1"
                        fi

                        if [  "$questionapp" == "umountcd" ]  ; then
                                printf "Unmount $1 "
                                echo `cat /etc/fstab | grep $1  | awk ' { print $2 }  '`
                                umount `cat /etc/fstab | grep $1  | awk ' { print $2 }  '`
                        fi

                        if [  "$questionapp" == "listisoless" ]  ; then
                                cat "$each" | less
                        fi

                done

                if  [ ! "$questionapp" == "append"  ]  &&  [ ! "$questionapp" == "skip"  ] ; then
                        clear
                        echo " "
                        echo "start burning $each ? so press enter ..."
                        echo "- if you would like to append the $each on dvd instead of create new media, type append followed by enter"
                        echo "- if you would like to skip $each on dvd instead of create new media, type skip followed by enter"
                        printf "CD$cdburncounter/:>"
                        read questionapp
                fi
 
 
                if [ "$questionapp" == "append"  ] ; then
                        echo "growisofs -M $1 -R -J < $each"
                        growisofs -M "$1" -R -J  -path-list "$each"
                        echo " $each burnt to $1"
                        let cdburncounter+=1
                        printf "The final size of the archive $cdburncounter over $cdburncountermax is "
                        echo `cat $4/filesz`
                        # echo $cdburncountermax cdburncounter
                fi


                if [ "$questionapp" == "skip"  ] ; then
                        echo "growisofs -M $1 -R -J < $each"
                        echo " $each skipped, to $1"
                        let cdburncounter+=1
                        printf "The final size of the archive $cdburncounter over $cdburncountermax is "
                        echo `cat $4/filesz`
                        # echo $cdburncountermax cdburncounter
                fi
 
                if [ ! "$questionapp" == "append"  ] &&  [ ! "$questionapp" == "skip"  ]  ; then
                        echo "growisofs -Z $1 -R -J < $each"
                        growisofs -Z "$1" -R -J -path-list  "$each"
                        echo " $each burnt to $1"
                        let cdburncounter+=1
                        printf "The final size of the archive $cdburncounter over $cdburncountermax is "
                        echo `cat $4/filesz`
                        # echo $cdburncountermax cdburncounter
                fi



               
                echo " "
                echo "Enter a new dvd media and press a key please"
                if [ ! "$3" == "--nosound" ]  ; then
                        #aplay /usr/share/sounds/KDE_Beep.ogg
                        beep
                fi
                if [ ! "$3" == "--noeject" ]  ; then
                        eject "$1"
                fi
                read lkfdjsjkdklfdsa
        done
fi


fi


##growisofs -Z /dev/hdb -R -J  -r -l -iso-level 2      -path-list bur/iso423

thanks !!

H_TeXMeX_H 02-10-2009 03:14 AM

So, what exactly does this do ? Backs up all HDD to DVD ? For what purpose ?

fotoguy 02-12-2009 06:31 AM

I know you have put some time into it, good effort, but for me it's only a backup script, there is quite a lot of them out there, it's nothing new. I made the same some years ago that I still run today, runs about 10 lines of bash code.

frenchn00b 03-03-2009 01:38 PM

Quote:

Originally Posted by H_TeXMeX_H (Post 3438129)
So, what exactly does this do ? Backs up all HDD to DVD ? For what purpose ?

you just have to put the cdrom or dvd, and it burns you the folder without compressing in tar.gz or asking you to slot in

dvd1 first
dvd 2
...
dvd25 to get a simple file, like a ghost or pkunzip, or partition magic

it is ordered and can burn many dvd of a single folder
it is also creating a file, with a virtual image of the disk so that you can get in 10sec which dvd number to seek out of your backusp.


I note that there isnt any similar script under linux for the moment.

There is few but are with gui and not as this one:
you can recover/ n backup an harddisk damaged with mepis/knoppix, even

it can be elaborated with our blue dialogs ... for terminals/bash

--
edited: sorry for the bad written english
if you are fluent writer, I may be interested thsi text to be corrected


All times are GMT -5. The time now is 05:54 PM.