From 8b7882a833092b5974aa73e06b2e55bb9d1a9e99 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Wed, 12 Sep 2001 10:21:48 +0000 Subject: [PATCH] Added Helmut Jarausch patch for restoring from multiple CD + examples. --- CHANGES | 8 ++++- dump.spec | 2 +- dump/tape.c | 3 +- examples/dump_on_cd/README | 53 ++++++++++++++++++++++++++++ examples/dump_on_cd/dump_userinfo.sh | 12 +++++++ examples/dump_on_cd/start_dump.sh | 24 +++++++++++++ examples/dump_on_cd/verify_dump.sh | 8 +++++ restore/main.c | 21 ++++++----- restore/restore.8.in | 16 +++++---- restore/restore.h | 3 +- restore/tape.c | 9 +++-- 11 files changed, 137 insertions(+), 22 deletions(-) create mode 100644 examples/dump_on_cd/README create mode 100755 examples/dump_on_cd/dump_userinfo.sh create mode 100755 examples/dump_on_cd/start_dump.sh create mode 100755 examples/dump_on_cd/verify_dump.sh diff --git a/CHANGES b/CHANGES index 328ead1..3906dbb 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.137 2001/09/12 09:02:51 stelian Exp $ +$Id: CHANGES,v 1.138 2001/09/12 10:21:48 stelian Exp $ Changes between versions 0.4b23 and 0.4b24 (released ?????????????) =================================================================== @@ -40,6 +40,12 @@ Changes between versions 0.4b23 and 0.4b24 (released ?????????????) 9. Updated the RPM spec file following the RedHat changes (dynamically linked binaries now in /usr/sbin etc). +10. Added a patch from Helmut Jarausch + which enables restore to recognise multi volume compressed dumps + done on CD. Included his scripts for dump (which pipe the dump + output directly into cdrecord) and restore. There is now + possible to to backups to CD on the fly! + Changes between versions 0.4b22 and 0.4b23 (released July 20, 2001) =================================================================== diff --git a/dump.spec b/dump.spec index e7d4a25..02bce2f 100644 --- a/dump.spec +++ b/dump.spec @@ -108,7 +108,7 @@ rm -rf %{buildroot} %files %defattr(-,root,root) %doc CHANGES COPYRIGHT KNOWNBUGS MAINTAINERS README REPORTING-BUGS THANKS TODO -%doc dump.lsm +%doc dump.lsm examples %attr(0664,root,disk) %config(noreplace) %{_sysconfdir}/dumpdates %attr(0755,root,root) /usr/sbin/dump /usr/sbin/rdump diff --git a/dump/tape.c b/dump/tape.c index 644ed8a..45535ea 100644 --- a/dump/tape.c +++ b/dump/tape.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: tape.c,v 1.56 2001/09/12 09:02:51 stelian Exp $"; + "$Id: tape.c,v 1.57 2001/09/12 10:21:49 stelian Exp $"; #endif /* not lint */ #include @@ -1122,6 +1122,7 @@ doslave(int cmd, int slave_number, int first) if (compressed && do_compress) { comp_buf->length = bufsize; worklen = TP_BSIZE + writesize; + compresult = 1; #ifdef HAVE_ZLIB if (!bzipflag) { compresult = compress2(comp_buf->buf, diff --git a/examples/dump_on_cd/README b/examples/dump_on_cd/README new file mode 100644 index 0000000..ae04ce5 --- /dev/null +++ b/examples/dump_on_cd/README @@ -0,0 +1,53 @@ + Experimental dump to CDROMs + =========================== + +Starting with dump/restore version 0.4b24 or later versions of +dump/restore you can dump to CDROMs. + +You need a (successfully installed) CD-writing software like + cdrecord (tested with versions 1.11a04 onwards) + +These scripts use the new switch ('V') to restore +which signals a multi-volume (non-tape) medium like CDROMs + +I have used the shell scripts below to generate/verify the dump + +YOU MUST MODIFY these - especially + +- adapt FS to the filesystem to be dumped +- UserExit to the path to the user exit function like UserInfo below +- FiFo to the path to a named pipe (better not on the same filesystem) +- your cd device(s) ( I have /dev/cdrom a symlink to /dev/sr0 and + /dev/cdrw a symlink to /dev/sr1 ) +- your path to cdrecord and +- - cdrecord's dev parameter must be adapted to your CD burner +- - cdrecord's fs (= input fifo size), use less than 64m if you + are short of memory +- - cdrecord's speed parameter : this parameter not only depends on the + capabilities of your CD burner BUT also on the speed of your CPU !!! + With the dump -z6 compression on a 900 MHz Pentium III I had no problems + with speed=4 which is the maximum speed for my burner. + It looks as if at least speed=6 would be possible on a 900 MHz Pentium III. + If speed is to large, cdrecord's input fifo gets empty (as + shown by cdrecord) and then you have a buffer underrun. + +- replace the wayplay command with something which alerts you if you + have to change CDROMS + +- for restore or verification replace /dev/cdrom by something + which applies for you (device for the CDreader) + + +DON'T FORGET to generate a boot-CD which has the 0.4b24 restore + or a newer version of restore on board + +I prefer timos_Rescue_Cd_Set-0.6.1 see http://rescuecd.sourceforge.net + + +Please Cc bug-reports to jarausch@igpm.rwth-aachen.de + +----------------------------------------------------------------- +This file and the scripts were slightly edited when the +Helmut Jarausch patch was integrated in dump-0.4b24. + Stelian. + diff --git a/examples/dump_on_cd/dump_userinfo.sh b/examples/dump_on_cd/dump_userinfo.sh new file mode 100755 index 0000000..9096048 --- /dev/null +++ b/examples/dump_on_cd/dump_userinfo.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# $1 = filename +# $2 = sequence number + +wavplay -q /root/alert.wav +num=$[$2+1] +echo "insert next CD (number $num) " +read -p "CD number $num ready? " Ans + +xterm -hold -T cdrecord_$num -e \ + /usr/local/bin/cdrecord dev=0,1,0 fs=64m \ + -v speed=4 -eject -pad -data $1 & diff --git a/examples/dump_on_cd/start_dump.sh b/examples/dump_on_cd/start_dump.sh new file mode 100755 index 0000000..df98c0a --- /dev/null +++ b/examples/dump_on_cd/start_dump.sh @@ -0,0 +1,24 @@ +#!/bin/bash +if [ `id -u` != 0 ]; then + echo "root priviledges are required" + exit 1 +fi +Level=0 +Label=`date -I` +#CD_Cap=650 +CD_Cap=700 +eval Cap=$(($CD_Cap*1024)) +FS=/ +UserExit=/root/dump_userinfo.sh +FiFo=/tmp/dump.fifo +rm -f $FiFo +mkfifo $FiFo +xterm -T cdrecord_1 -hold -e cdrecord dev=0,1,0 fs=64m \ + -v speed=4 -eject -pad -data $FiFo & + +/sbin/dump -z6 -b64 -B$Cap -F $UserExit \ + -$Level -L $Label -f $FiFo $FS + +wavplay -q /root/alert.wav +rm -f $FiFo + diff --git a/examples/dump_on_cd/verify_dump.sh b/examples/dump_on_cd/verify_dump.sh new file mode 100755 index 0000000..2b19702 --- /dev/null +++ b/examples/dump_on_cd/verify_dump.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [ `id -u` != 0 ]; then + echo "root priviledges are required" + exit 1 +fi +cd / +/sbin/restore -V -b64 -C -f /dev/cdrom diff --git a/restore/main.c b/restore/main.c index 3feca82..8368548 100644 --- a/restore/main.c +++ b/restore/main.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: main.c,v 1.28 2001/08/14 13:11:58 stelian Exp $"; + "$Id: main.c,v 1.29 2001/09/12 10:21:49 stelian Exp $"; #endif /* not lint */ #include @@ -81,7 +81,7 @@ static const char rcsid[] = #include "extern.h" int bflag = 0, cvtflag = 0, dflag = 0, vflag = 0, yflag = 0; -int hflag = 1, mflag = 1, Mflag = 0, Nflag = 0, zflag = 0; +int hflag = 1, mflag = 1, Mflag = 0, Nflag = 0, Vflag = 0, zflag = 0; int uflag = 0; int dokerberos = 0; char command = '\0'; @@ -162,7 +162,7 @@ main(int argc, char *argv[]) #ifdef USE_QFA "Q:" #endif - "Rrs:tT:uvxX:y")) != -1) + "Rrs:tT:uvVxX:y")) != -1) switch(ch) { case 'b': /* Change default tape blocksize. */ @@ -243,6 +243,9 @@ main(int argc, char *argv[]) case 'v': vflag = 1; break; + case 'V': + Vflag = 1; + break; case 'X': if( !strcmp(optarg,"-") ) { use_stdin("-X"); @@ -525,12 +528,12 @@ usage(void) (void)fprintf(stderr, "usage:\t%s%s\n\t%s%s\n\t%s%s\n\t%s%s\n\t%s%s\n\t%s%s\n", - __progname, " -C [-c" kerbflag "Mvy] [-b blocksize] [-D filesystem] [-f file] [-F script] [-s fileno]", - __progname, " -i [-ch" kerbflag "mMuvy] [-b blocksize] [-f file] [-F script] " qfaflag "[-s fileno]", - __progname, " -r [-c" kerbflag "Muvy] [-b blocksize] [-f file] [-F script] [-s fileno] [-T directory]", - __progname, " -R [-c" kerbflag "Muvy] [-b blocksize] [-f file] [-F script] [-s fileno] [-T directory]", - __progname, " -t [-ch" kerbflag "Muvy] [-b blocksize] [-f file] [-F script] " qfaflag "[-s fileno] [-X filelist] [file ...]", - __progname, " -x [-ch" kerbflag "mMuvy] [-b blocksize] [-f file] [-F script] " qfaflag "[-s fileno] [-X filelist] [file ...]"); + __progname, " -C [-c" kerbflag "MvVy] [-b blocksize] [-D filesystem] [-f file] [-F script] [-s fileno]", + __progname, " -i [-ch" kerbflag "mMuvVy] [-b blocksize] [-f file] [-F script] " qfaflag "[-s fileno]", + __progname, " -r [-c" kerbflag "MuvVy] [-b blocksize] [-f file] [-F script] [-s fileno] [-T directory]", + __progname, " -R [-c" kerbflag "MuvVy] [-b blocksize] [-f file] [-F script] [-s fileno] [-T directory]", + __progname, " -t [-ch" kerbflag "MuvVy] [-b blocksize] [-f file] [-F script] " qfaflag "[-s fileno] [-X filelist] [file ...]", + __progname, " -x [-ch" kerbflag "mMuvVy] [-b blocksize] [-f file] [-F script] " qfaflag "[-s fileno] [-X filelist] [file ...]"); exit(1); } diff --git a/restore/restore.8.in b/restore/restore.8.in index 96d91a8..b13346a 100644 --- a/restore/restore.8.in +++ b/restore/restore.8.in @@ -29,7 +29,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: restore.8.in,v 1.16 2001/07/18 13:12:33 stelian Exp $ +.\" $Id: restore.8.in,v 1.17 2001/09/12 10:21:49 stelian Exp $ .\" .Dd __DATE__ .Dt RESTORE 8 @@ -40,7 +40,7 @@ .Sh SYNOPSIS .Nm restore .Fl C -.Op Fl ckMvy +.Op Fl ckMvVy .Op Fl b Ar blocksize .Op Fl D Ar filesystem .Op Fl f Ar file @@ -49,7 +49,7 @@ .Op Fl T Ar directory .Nm restore .Fl i -.Op Fl chkmMNuvy +.Op Fl chkmMNuvVy .Op Fl b Ar blocksize .Op Fl f Ar file .Op Fl F Ar script @@ -58,7 +58,7 @@ .Op Fl T Ar directory .Nm restore .Fl R -.Op Fl ckMNuvy +.Op Fl ckMNuvVy .Op Fl b Ar blocksize .Op Fl f Ar file .Op Fl F Ar script @@ -66,7 +66,7 @@ .Op Fl T Ar directory .Nm restore .Fl r -.Op Fl ckMNuvy +.Op Fl ckMNuvVy .Op Fl b Ar blocksize .Op Fl f Ar file .Op Fl F Ar script @@ -74,7 +74,7 @@ .Op Fl T Ar directory .Nm restore .Fl t -.Op Fl chkMNuvy +.Op Fl chkMNuvVy .Op Fl b Ar blocksize .Op Fl f Ar file .Op Fl F Ar script @@ -85,7 +85,7 @@ .Op file ... .Nm restore .Fl x -.Op Fl chkmMNuvy +.Op Fl chkmMNuvVy .Op Fl b Ar blocksize .Op Fl f Ar file .Op Fl F Ar script @@ -433,6 +433,8 @@ The (verbose) flag causes it to type the name of each file it treats preceded by its file type. +.It Fl V +Enables reading multi-volume non-tape mediums like CDROMs. .It Fl X Ar filelist Read list of files to be listed or extracted from the text file .Ar filelist diff --git a/restore/restore.h b/restore/restore.h index 81dfdc7..8e35380 100644 --- a/restore/restore.h +++ b/restore/restore.h @@ -5,7 +5,7 @@ * Stelian Pop , 1999-2000 * Stelian Pop - AlcĂ´ve , 2000 * - * $Id: restore.h,v 1.17 2001/08/13 16:17:52 stelian Exp $ + * $Id: restore.h,v 1.18 2001/09/12 10:21:49 stelian Exp $ */ /* @@ -57,6 +57,7 @@ extern int dflag; /* print out debugging info */ extern int hflag; /* restore heirarchies */ extern int mflag; /* restore by name instead of inode number */ extern int Mflag; /* multi-volume restore */ +extern int Vflag; /* multi-volume on a single device like CDROM */ extern int Nflag; /* do not write the disk */ extern int uflag; /* unlink symlink targets */ extern int vflag; /* print out actions taken */ diff --git a/restore/tape.c b/restore/tape.c index fb5c816..344ca3b 100644 --- a/restore/tape.c +++ b/restore/tape.c @@ -46,7 +46,7 @@ #ifndef lint static const char rcsid[] = - "$Id: tape.c,v 1.46 2001/08/16 15:24:22 stelian Exp $"; + "$Id: tape.c,v 1.47 2001/09/12 10:21:49 stelian Exp $"; #endif /* not lint */ #include @@ -1492,6 +1492,9 @@ readtape_comprfile(char *buf) /* read the block prefix */ ret = read_a_block(mt, tapebuf, PREFIXSIZE, &rl); + + if (Vflag && (ret == 0 || rl < PREFIXSIZE || tpb->length == 0)) + ret = 0; if (ret <= 0) goto readerr; @@ -1932,7 +1935,9 @@ setmagtapein(void) { magtapein = ioctl(mt, MTIOCGET, (char *)&mt_stat) == 0; } - Vprintf(stdout,"Input is from %s\n", magtapein? "tape": "file/pipe"); + Vprintf(stdout,"Input is from %s\n", + magtapein ? "tape" : + Vflag ? "multi-volume (no tape)" : "file/pipe"); } /* -- 2.39.2