LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-09-2009, 10:20 PM   #1
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

Rep: Reputation: 50
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 !!

Last edited by frenchn00b; 02-09-2009 at 10:24 PM.
 
Old 02-10-2009, 03:14 AM   #2
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
So, what exactly does this do ? Backs up all HDD to DVD ? For what purpose ?
 
Old 02-12-2009, 06:31 AM   #3
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: KirraMail Live Email Server
Posts: 1,276

Rep: Reputation: 61
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.
 
Old 03-03-2009, 01:38 PM   #4
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

Original Poster
Rep: Reputation: 50
Quote:
Originally Posted by H_TeXMeX_H View Post
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

Last edited by frenchn00b; 03-03-2009 at 01:42 PM.
 
  


Reply

Tags
backup


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with dvdbackup jdavis2 Linux - Software 0 08-14-2007 10:30 PM
dvdbackup not working Alinuxnoob Linux - Software 1 10-23-2004 07:56 PM
dvdbackup Error theeeg Linux - Software 5 06-17-2004 08:25 PM
dvdbackup or K3b? brent1a Linux - Software 4 05-23-2004 11:59 PM
Low Harddisk space. Can I just transfer the entire Linux to a bigger harddisk? davidas Linux - Newbie 12 04-13-2004 02:03 AM


All times are GMT -5. The time now is 11:44 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration