| 1 | #!/bin/bash |
| 2 | # This script dumps the specified Filesystem via dump on a CD/DVD |
| 3 | # CD_CAPACITY defines the capacity in MB per CD |
| 4 | # The script for the next volume is passed via the -F option of dump |
| 5 | # At least for my DVD-Recorder (a PHILIPS DVR-A03) it is necessary |
| 6 | # to define the tracksize for the next track before the DVD is written. |
| 7 | # This is done via the -tsize option of cdrecord. Since tsize takes its |
| 8 | # arguments in Bytes, the shell cannot compute the value correctly |
| 9 | # anymore (value too high), so I use bc. |
| 10 | |
| 11 | # !!! If you plan to write DVD's with other sizes, please correct the |
| 12 | # CD_CAPACITY in the dump_userexit_DVD script, too !!! |
| 13 | |
| 14 | COMPRESSION_LEVEL=2 |
| 15 | RECORD_BIN="/usr/bin/dvdrecord dev=0,0,0 fs=64M speed=2 " |
| 16 | EXITSCRIPT="/root/bin/dvd_dump_userexit" |
| 17 | FILESYSTEM="/home" |
| 18 | LEVEL=0 |
| 19 | LABEL="`date -I`" |
| 20 | CD_CAPACITY=4300 |
| 21 | TSIZE="$(echo "$CD_CAPACITY*1024*1024" | bc -l )" |
| 22 | BSIZE="$(echo "$CD_CAPACITY*1024" | bc -l )" |
| 23 | FIFO="/tmp/dump.fifo" |
| 24 | DUMP_BIN="/usr/sbin/dump -z$COMPRESSION_LEVEL -b64 -B$BSIZE -F $EXITSCRIPT -$LEVEL -L $LABEL -f $FIFO $FILESYSTEM" |
| 25 | |
| 26 | rm -f $FIFO |
| 27 | mkfifo $FIFO |
| 28 | ANSWER="" |
| 29 | while [ "$ANSWER" != "y" ] ; do |
| 30 | read -p "Did you insert DVD No. 1? (y/n)" ANSWER |
| 31 | if [ "$ANSWER" == "y" ] ; then |
| 32 | $RECORD_BIN -blank=fast |
| 33 | $RECORD_BIN -eject -dao -pad -tsize=$TSIZE -data $FIFO & |
| 34 | $DUMP_BIN |
| 35 | rm -f $FIFO |
| 36 | exit 0 |
| 37 | elif [ "$ANSWER" == "n" ] ; then |
| 38 | EXIT="" |
| 39 | read -p "Do you really want to exit? (y/n)" EXIT |
| 40 | if [ "$EXIT" == "y" ] ; then |
| 41 | exit 1 |
| 42 | fi |
| 43 | fi |
| 44 | done |