From e46507f206f7adcb8d2e218963d2115236e86604 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Tue, 14 Aug 2001 13:11:58 +0000 Subject: [PATCH 01/16] Fixed restore to use the full volume path when doing a compare. --- CHANGES | 6 +++++- restore/main.c | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index ff90fc7..72a61c3 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.130 2001/08/13 16:17:52 stelian Exp $ +$Id: CHANGES,v 1.131 2001/08/14 13:11:58 stelian Exp $ Changes between versions 0.4b23 and 0.4b24 (released ?????????????) =================================================================== @@ -9,6 +9,10 @@ Changes between versions 0.4b23 and 0.4b24 (released ?????????????) definition was a complete mess, making possible to have objects overlap). +3. Fixed restore to use the full tape volume path when doing + a compare (since it changes the working directory to the + filesystem being compared in the process). + Changes between versions 0.4b22 and 0.4b23 (released July 20, 2001) =================================================================== diff --git a/restore/main.c b/restore/main.c index 8d9c6d2..3feca82 100644 --- a/restore/main.c +++ b/restore/main.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: main.c,v 1.27 2001/08/13 16:17:52 stelian Exp $"; + "$Id: main.c,v 1.28 2001/08/14 13:11:58 stelian Exp $"; #endif /* not lint */ #include @@ -277,7 +277,19 @@ main(int argc, char *argv[]) atexit(cleanup); - setinput(inputdev); + if (command == 'C' && inputdev[0] != '/') { + /* since we chdir into the directory we are comparing + * to, we must retain the full tape path */ + char wd[MAXPATHLEN], fullpathinput[MAXPATHLEN]; + if (!getcwd(wd, MAXPATHLEN)) + err(1, "can't get current directory"); + snprintf(fullpathinput, MAXPATHLEN, "%s/%s", wd, inputdev); + fullpathinput[MAXPATHLEN - 1] = '\0'; +printf("FULLPATH is %s\n", fullpathinput); + setinput(fullpathinput); + } + else + setinput(inputdev); if (argc == 0 && !filelist) { argc = 1; -- 2.39.2 From e084ba00f03da98a6d260b0b3856aee2dfbb4c58 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Thu, 16 Aug 2001 09:37:57 +0000 Subject: [PATCH 02/16] Makes dump abort (-q option) whenever it needs operator attention. --- CHANGES | 6 +++++- dump/dump.8.in | 9 +++++++-- dump/dump.h | 3 ++- dump/main.c | 11 ++++++++--- dump/optr.c | 8 +++++++- 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 72a61c3..204f3eb 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.131 2001/08/14 13:11:58 stelian Exp $ +$Id: CHANGES,v 1.132 2001/08/16 09:37:57 stelian Exp $ Changes between versions 0.4b23 and 0.4b24 (released ?????????????) =================================================================== @@ -13,6 +13,10 @@ Changes between versions 0.4b23 and 0.4b24 (released ?????????????) a compare (since it changes the working directory to the filesystem being compared in the process). +4. Added the -q option to dump which makes dump abort + whenever it needs operator attention. It should be + easier to use dump in scripts with this option. + Changes between versions 0.4b22 and 0.4b23 (released July 20, 2001) =================================================================== diff --git a/dump/dump.8.in b/dump/dump.8.in index abbda73..206356b 100644 --- a/dump/dump.8.in +++ b/dump/dump.8.in @@ -30,7 +30,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: dump.8.in,v 1.30 2001/07/19 09:03:44 stelian Exp $ +.\" $Id: dump.8.in,v 1.31 2001/08/16 09:37:59 stelian Exp $ .\" .Dd __DATE__ .Dt DUMP 8 @@ -40,7 +40,7 @@ .Nd ext2 filesystem backup .Sh SYNOPSIS .Nm dump -.Op Fl 0123456789ackMnSu +.Op Fl 0123456789ackMnqSu .Op Fl B Ar records .Op Fl b Ar blocksize .Op Fl d Ar density @@ -253,6 +253,11 @@ notify all operators in the group .Dq operator by means similar to a .Xr wall 1 . +.It Fl q +Make +.Nm +abort immediately whenever operator attention is required, +without prompting in case of write errors, tape changes etc. .It Fl Q Ar file Enable the Quick File Access support. Tape positions for each inode are stored into the file diff --git a/dump/dump.h b/dump/dump.h index 4836ba8..0e276b5 100644 --- a/dump/dump.h +++ b/dump/dump.h @@ -5,7 +5,7 @@ * Stelian Pop , 1999-2000 * Stelian Pop - Alcôve , 2000 * - * $Id: dump.h,v 1.30 2001/08/13 16:17:52 stelian Exp $ + * $Id: dump.h,v 1.31 2001/08/16 09:37:59 stelian Exp $ */ /*- @@ -75,6 +75,7 @@ extern char lastlevel; /* dump level of previous dump */ extern char level; /* dump level of this dump */ extern int uflag; /* update flag */ extern int Mflag; /* multi-volume flag */ +extern int qflag; /* quit on errors flag */ extern char *eot_script; /* end of volume script fiag */ extern int diskfd; /* disk file descriptor */ extern int tapefd; /* tape file descriptor */ diff --git a/dump/main.c b/dump/main.c index 7a5884b..8fcf468 100644 --- a/dump/main.c +++ b/dump/main.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: main.c,v 1.56 2001/08/13 16:17:52 stelian Exp $"; + "$Id: main.c,v 1.57 2001/08/16 09:37:59 stelian Exp $"; #endif /* not lint */ #include @@ -104,6 +104,7 @@ char lastlevel; /* dump level of previous dump */ char level; /* dump level of this dump */ int uflag; /* update flag */ int Mflag; /* multi-volume flag */ +int qflag; /* quit on errors flag */ char *eot_script; /* end of volume script fiag */ int diskfd; /* disk file descriptor */ int tapefd; /* tape file descriptor */ @@ -235,7 +236,7 @@ main(int argc, char *argv[]) #ifdef KERBEROS "k" #endif - "Mn" + "Mnq" #ifdef USE_QFA "Q:" #endif @@ -345,6 +346,10 @@ main(int argc, char *argv[]) notify = 1; break; + case 'q': + qflag = 1; + break; + #ifdef USE_QFA case 'Q': /* create tapeposfile */ gTapeposfile = optarg; @@ -949,7 +954,7 @@ usage(void) #ifdef KERBEROS "k" #endif - "MnSu" + "MnqSu" "] [-B records] [-b blocksize] [-d density]\n" "\t%s [-e inode#,inode#,...] [-E file] [-f file] [-h level] " #ifdef USE_QFA diff --git a/dump/optr.c b/dump/optr.c index d1cdf1d..cd98e66 100644 --- a/dump/optr.c +++ b/dump/optr.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: optr.c,v 1.25 2001/07/18 09:12:05 stelian Exp $"; + "$Id: optr.c,v 1.26 2001/08/16 09:37:59 stelian Exp $"; #endif /* not lint */ #include @@ -106,6 +106,12 @@ query(const char *question) FILE *mytty; time_t firstprompt, when_answered; + if (qflag) { + msg("%s - forced abort\n", question); + dumpabort(0); + /* NOTREACHED */ + } + firstprompt = time(NULL); if ((mytty = fopen(_PATH_TTY, "r")) == NULL) -- 2.39.2 From 8cef350eb9ffa2e543a95756a8f605175380f7b0 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Thu, 16 Aug 2001 13:12:30 +0000 Subject: [PATCH 03/16] Refuse incompatible options in dump (-a and -B). --- CHANGES | 5 ++++- dump/main.c | 27 ++++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 204f3eb..ffbb11d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.132 2001/08/16 09:37:57 stelian Exp $ +$Id: CHANGES,v 1.133 2001/08/16 13:12:30 stelian Exp $ Changes between versions 0.4b23 and 0.4b24 (released ?????????????) =================================================================== @@ -17,6 +17,9 @@ Changes between versions 0.4b23 and 0.4b24 (released ?????????????) whenever it needs operator attention. It should be easier to use dump in scripts with this option. +5. Detect the use of incompatible options to dump and + refuse them (like -a and -B options together). + Changes between versions 0.4b22 and 0.4b23 (released July 20, 2001) =================================================================== diff --git a/dump/main.c b/dump/main.c index 8fcf468..8f33f95 100644 --- a/dump/main.c +++ b/dump/main.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: main.c,v 1.57 2001/08/16 09:37:59 stelian Exp $"; + "$Id: main.c,v 1.58 2001/08/16 13:12:30 stelian Exp $"; #endif /* not lint */ #include @@ -178,6 +178,7 @@ static void obsolete __P((int *, char **[])); static void usage __P((void)); static void do_exclude_from_file __P((char *)); static void do_exclude_ino_str __P((char *)); +static void incompat_flags __P((int, char, char)); static dump_ino_t iexclude_list[IEXCLUDE_MAXNUM];/* the inode exclude list */ static int iexclude_num = 0; /* number of elements in the list */ @@ -191,7 +192,8 @@ main(int argc, char *argv[]) register struct fstab *dt; register char *map; register int ch; - int i, anydirskipped, bflag = 0, Tflag = 0, honorlevel = 1; + int i, anydirskipped; + int aflag = 0, bflag = 0, Tflag = 0, honorlevel = 1; dump_ino_t maxino; struct STAT statbuf; dev_t filedev = 0; @@ -254,6 +256,7 @@ main(int argc, char *argv[]) case 'a': /* `auto-size', Write to EOM. */ unlimited = 1; + aflag = 1; break; case 'B': /* blocks per output file */ @@ -411,11 +414,12 @@ main(int argc, char *argv[]) exit(X_STARTUP); } argc--; - if (Tflag && uflag) { - msg("You cannot use the T and u flags together.\n"); - msg("The ENTIRE dump is aborted.\n"); - exit(X_STARTUP); - } + incompat_flags(Tflag && uflag, 'T', 'u'); + incompat_flags(aflag && blocksperfile, 'a', 'B'); + incompat_flags(aflag && cartridge, 'a', 'c'); + incompat_flags(aflag && density, 'a', 'd'); + incompat_flags(aflag && tsize, 'a', 's'); + if (strcmp(tapeprefix, "-") == 0) { pipeout++; tapeprefix = "standard output"; @@ -1184,3 +1188,12 @@ do_exclude_from_file(char *file) { } fclose(f); } + +static void incompat_flags(int cond, char flag1, char flag2) { + if (cond) { + msg("You cannot use the %c and %c flags together.\n", + flag1, flag2); + msg("The ENTIRE dump is aborted.\n"); + exit(X_STARTUP); + } +} -- 2.39.2 From 9acd7300abe443604006c511d46a90f54aa55349 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Thu, 16 Aug 2001 13:15:21 +0000 Subject: [PATCH 04/16] make the list up to date. --- TODO | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/TODO b/TODO index 61fbfb7..dd4b7ff 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -$Id: TODO,v 1.21 2001/07/25 13:21:31 stelian Exp $ +$Id: TODO,v 1.22 2001/08/16 13:15:21 stelian Exp $ Need to verify: --------------- @@ -40,22 +40,11 @@ All others: ufsrestore(1M) to determine whether a file is in the dump file that is being restored. -8. Modify (or get rid of) rmt in order to work with non Linux - systems (limited succes has been reported). A good version - of rmt to be looked at is part of star - http://www.fokus.gmd.de/research/cc/glone/employees/joerg.schilling/private/star.html - -9. EA/ACL support in dump (requested by Michael Ju. Tokarev +8. EA/ACL support in dump (requested by Michael Ju. Tokarev . -10. Better readline completition in restore (escape spaces etc). +9. Better readline completition in restore (escape spaces etc). -11. Dump compiled with RedHat's 7.0 gcc seems to hang for some +10. Dump compiled with RedHat's 7.0 gcc seems to hang for some people. When compiled with kgcc all the problems disappear. Will the RedHat's 7.1 gcc resolve this ? - -12. Dump uses /dev/tty for reporting some messages. When invoked - from a script, /dev/tty may not exist. Why not using just - stderr ? - -13. -a and -B option to dump are exclusive. -- 2.39.2 From 88ef261eaffd1b09f23eb73d8259336f694d9324 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Thu, 16 Aug 2001 15:24:21 +0000 Subject: [PATCH 05/16] Added bzip2 compression to dump. --- CHANGES | 9 +- TODO | 14 ++- compat/include/protocols/dumprestore.h | 8 +- config.h.in | 3 + configure | 125 +++++++++++++++++++++---- configure.in | 13 +++ dump/Makefile.in | 4 +- dump/dump.8.in | 12 ++- dump/dump.h | 3 +- dump/main.c | 28 +++++- dump/tape.c | 61 +++++++++--- restore/Makefile.in | 4 +- restore/tape.c | 120 +++++++++++++++++------- 13 files changed, 320 insertions(+), 84 deletions(-) diff --git a/CHANGES b/CHANGES index ffbb11d..dccc4ed 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.133 2001/08/16 13:12:30 stelian Exp $ +$Id: CHANGES,v 1.134 2001/08/16 15:24:21 stelian Exp $ Changes between versions 0.4b23 and 0.4b24 (released ?????????????) =================================================================== @@ -20,6 +20,13 @@ Changes between versions 0.4b23 and 0.4b24 (released ?????????????) 5. Detect the use of incompatible options to dump and refuse them (like -a and -B options together). +6. Added bzip2 compression to dump/restore (use option -j level + to select it). Note that you will need a restore version + >= 0.4b24 in order to restore a bzip2 compressed dump. + The same warning as for the zlib compression applies: + the tape format of a bzip2 dump is not compatible with the + original BSD tape format. + Changes between versions 0.4b22 and 0.4b23 (released July 20, 2001) =================================================================== diff --git a/TODO b/TODO index dd4b7ff..a928652 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -$Id: TODO,v 1.22 2001/08/16 13:15:21 stelian Exp $ +$Id: TODO,v 1.23 2001/08/16 15:24:21 stelian Exp $ Need to verify: --------------- @@ -29,22 +29,20 @@ All others: 4. Implement a DEBUG option which doesn't fork on each tape, making it able to debug dump with gdb. -5. Extend the compression patch to use bzip2. +5. Make a bootable dump tape? I don't know if it is possible... -6. Make a bootable dump tape? I don't know if it is possible... - -7. From Kjetil Torgrim Homme : +6. From Kjetil Torgrim Homme : a archive_file Archive file. Archive a dump table-of-contents in the specified archive_file to be used by ufsrestore(1M) to determine whether a file is in the dump file that is being restored. -8. EA/ACL support in dump (requested by Michael Ju. Tokarev +7. EA/ACL support in dump (requested by Michael Ju. Tokarev . -9. Better readline completition in restore (escape spaces etc). +8. Better readline completition in restore (escape spaces etc). -10. Dump compiled with RedHat's 7.0 gcc seems to hang for some +9. Dump compiled with RedHat's 7.0 gcc seems to hang for some people. When compiled with kgcc all the problems disappear. Will the RedHat's 7.1 gcc resolve this ? diff --git a/compat/include/protocols/dumprestore.h b/compat/include/protocols/dumprestore.h index 885b9e0..49e14f1 100644 --- a/compat/include/protocols/dumprestore.h +++ b/compat/include/protocols/dumprestore.h @@ -5,7 +5,7 @@ * Stelian Pop , 1999-2000 * Stelian Pop - Alcôve , 2000 * - * $Id: dumprestore.h,v 1.13 2001/05/12 11:36:12 stelian Exp $ + * $Id: dumprestore.h,v 1.14 2001/08/16 15:24:21 stelian Exp $ */ /* @@ -123,6 +123,12 @@ union u_spcl { #define DR_NEWINODEFMT 0x0002 /* new format inodes on tape */ #define DR_COMPRESSED 0x0080 /* dump tape is compressed */ +/* + * compression flags for the tapebuf header. + */ +#define COMPRESS_ZLIB 0 +#define COMPRESS_BZLIB 1 + /* used for compressed dump tapes */ struct tapebuf { unsigned int compressed:1; diff --git a/config.h.in b/config.h.in index c64ec5d..7bb86b6 100644 --- a/config.h.in +++ b/config.h.in @@ -65,6 +65,9 @@ /* Define this if you have zlib compression library */ #undef HAVE_ZLIB +/* Define this if you have bzlib compression library */ +#undef HAVE_BZLIB + /* Define this if you want Quick File Access support */ #undef USE_QFA diff --git a/configure b/configure index 3c4404c..3e461eb 100755 --- a/configure +++ b/configure @@ -2050,15 +2050,101 @@ else fi +ac_safe=`echo "bzlib.h" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for bzlib.h""... $ac_c" 1>&6 +echo "configure:2056: checking for bzlib.h" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2066: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + bzlib_h=yes +else + echo "$ac_t""no" 1>&6 +bzlib_h=no +fi + +echo $ac_n "checking for BZ2_bzBuffToBuffCompress in -lbz2""... $ac_c" 1>&6 +echo "configure:2089: checking for BZ2_bzBuffToBuffCompress in -lbz2" >&5 +ac_lib_var=`echo bz2'_'BZ2_bzBuffToBuffCompress | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lbz2 $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + bzlib_lib=yes +else + echo "$ac_t""no" 1>&6 +bzlib_lib=no +fi + +if test "$bzlib_h" = yes -a "$bzlib_lib" = yes; then + BZLIB="-lbz2" + cat >> confdefs.h <<\EOF +#define HAVE_BZLIB 1 +EOF + +else + BZLIB="" +fi + + for ac_func in err errx verr verrx vwarn vwarnx warn warnx realpath lchown do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2057: checking for $ac_func" >&5 +echo "configure:2143: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2171: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2106,12 +2192,12 @@ fi done echo $ac_n "checking for glob""... $ac_c" 1>&6 -echo "configure:2110: checking for glob" >&5 +echo "configure:2196: checking for glob" >&5 if eval "test \"`echo '$''{'ac_cv_func_glob'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2224: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_glob=yes" else @@ -2155,10 +2241,10 @@ fi echo $ac_n "checking for extended glob routines""... $ac_c" 1>&6 -echo "configure:2159: checking for extended glob routines" >&5 +echo "configure:2245: checking for extended glob routines" >&5 if test "$ac_cv_func_glob" = "yes"; then cat > conftest.$ac_ext < @@ -2189,12 +2275,12 @@ rm -f conftest* fi echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:2193: checking for ANSI C header files" >&5 +echo "configure:2279: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2202,7 +2288,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2206: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2292: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2219,7 +2305,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -2237,7 +2323,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -2258,7 +2344,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -2269,7 +2355,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:2273: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2359: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -2293,12 +2379,12 @@ EOF fi echo $ac_n "checking for quad_t""... $ac_c" 1>&6 -echo "configure:2297: checking for quad_t" >&5 +echo "configure:2383: checking for quad_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_quad_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -2326,12 +2412,12 @@ EOF fi echo $ac_n "checking for u_quad_t""... $ac_c" 1>&6 -echo "configure:2330: checking for u_quad_t" >&5 +echo "configure:2416: checking for u_quad_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_u_quad_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -2539,6 +2625,7 @@ s%@MANMODE@%$MANMODE%g s%@DUMPDATESPATH@%$DUMPDATESPATH%g s%@CPP@%$CPP%g s%@ZLIB@%$ZLIB%g +s%@BZLIB@%$BZLIB%g s%@top_builddir@%$top_builddir%g CEOF diff --git a/configure.in b/configure.in index fc28967..e8bc852 100644 --- a/configure.in +++ b/configure.in @@ -368,6 +368,19 @@ else fi AC_SUBST(ZLIB) +dnl +dnl Check for bzlib headers and libraries +dnl +AC_CHECK_HEADER(bzlib.h, [bzlib_h=yes], [bzlib_h=no]) +AC_CHECK_LIB(bz2, BZ2_bzBuffToBuffCompress, [bzlib_lib=yes], [bzlib_lib=no]) +if test "$bzlib_h" = yes -a "$bzlib_lib" = yes; then + BZLIB="-lbz2" + AC_DEFINE(HAVE_BZLIB) +else + BZLIB="" +fi +AC_SUBST(BZLIB) + dnl dnl Check for library functions dnl diff --git a/dump/Makefile.in b/dump/Makefile.in index 19f2aca..52b7c15 100644 --- a/dump/Makefile.in +++ b/dump/Makefile.in @@ -1,4 +1,4 @@ -# $Id: Makefile.in,v 1.7 2001/04/12 16:03:29 stelian Exp $ +# $Id: Makefile.in,v 1.8 2001/08/16 15:24:21 stelian Exp $ top_srcdir= @top_srcdir@ srcdir= @srcdir@ @@ -7,7 +7,7 @@ srcdir= @srcdir@ CFLAGS= @CCOPTS@ -pipe $(OPT) $(GINC) $(INC) $(DEFS) @DUMPDEBUG@ LDFLAGS:= $(LDFLAGS) @STATIC@ -LIBS= $(GLIBS) @ZLIB@ +LIBS= $(GLIBS) @ZLIB@ @BZLIB@ DEPLIBS= ../compat/lib/libcompat.a PROG= dump diff --git a/dump/dump.8.in b/dump/dump.8.in index 206356b..129001c 100644 --- a/dump/dump.8.in +++ b/dump/dump.8.in @@ -30,7 +30,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: dump.8.in,v 1.31 2001/08/16 09:37:59 stelian Exp $ +.\" $Id: dump.8.in,v 1.32 2001/08/16 15:24:21 stelian Exp $ .\" .Dd __DATE__ .Dt DUMP 8 @@ -49,6 +49,7 @@ .Op Fl f Ar file .Op Fl F Ar script .Op Fl h Ar level +.Op Fl j Ar compression level .Op Fl L Ar label .Op Fl Q Ar file .Op Fl s Ar feet @@ -220,6 +221,15 @@ For security reasons, .Nm reverts back to the real user ID and the real group ID before running the script. +.It Fl j Ar compression level +Compress every block to be written on the tape using bzlib library. This +option will work only when dumping to a file or pipe or, when dumping +to a tape drive, if the tape drive is capable of writing variable +length blocks. You will need at least the 0.4b24 version of restore in +order to extract compressed tapes. Tapes written using compression will +not be compatible with the BSD tape format. The (optional) parameter +specifies the compression level bzlib will use. The default compression +level is 2. .It Fl k Use Kerberos authentication to talk to remote tape servers. (Only available if this option was enabled when diff --git a/dump/dump.h b/dump/dump.h index 0e276b5..4f46fa4 100644 --- a/dump/dump.h +++ b/dump/dump.h @@ -5,7 +5,7 @@ * Stelian Pop , 1999-2000 * Stelian Pop - Alcôve , 2000 * - * $Id: dump.h,v 1.31 2001/08/16 09:37:59 stelian Exp $ + * $Id: dump.h,v 1.32 2001/08/16 15:24:21 stelian Exp $ */ /*- @@ -73,6 +73,7 @@ extern char *tapeprefix; /* prefix of the tape file */ extern char *dumpdates; /* name of the file containing dump date information*/ extern char lastlevel; /* dump level of previous dump */ extern char level; /* dump level of this dump */ +extern int bzipflag; /* compression is done using bzlib */ extern int uflag; /* update flag */ extern int Mflag; /* multi-volume flag */ extern int qflag; /* quit on errors flag */ diff --git a/dump/main.c b/dump/main.c index 8f33f95..5e9c111 100644 --- a/dump/main.c +++ b/dump/main.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: main.c,v 1.58 2001/08/16 13:12:30 stelian Exp $"; + "$Id: main.c,v 1.59 2001/08/16 15:24:21 stelian Exp $"; #endif /* not lint */ #include @@ -102,6 +102,7 @@ char *tapeprefix; /* prefix of the tape file */ char *dumpdates; /* name of the file containing dump date information*/ char lastlevel; /* dump level of previous dump */ char level; /* dump level of this dump */ +int bzipflag; /* compression is done using bzlib */ int uflag; /* update flag */ int Mflag; /* multi-volume flag */ int qflag; /* quit on errors flag */ @@ -234,7 +235,11 @@ main(int argc, char *argv[]) #endif /* USE_QFA */ while ((ch = getopt(argc, argv, - "0123456789aB:b:cd:e:E:f:F:h:L:" + "0123456789aB:b:cd:e:E:f:F:h:" +#ifdef HAVE_BZLIB + "j::" +#endif + "L:" #ifdef KERBEROS "k" #endif @@ -318,6 +323,15 @@ main(int argc, char *argv[]) honorlevel = numarg("honor level", 0L, 10L); break; +#ifdef HAVE_BZLIB + case 'j': + compressed = 2; + bzipflag = 1; + if (optarg) + compressed = numarg("compress level", 1L, 9L); + break; +#endif /* HAVE_BZLIB */ + #ifdef KERBEROS case 'k': dokerberos = 1; @@ -693,8 +707,8 @@ main(int argc, char *argv[]) msg("Label: %s\n", spcl.c_label); if (compressed) - msg("Compressing output at compression level %d\n", - compressed); + msg("Compressing output at compression level %d (%s)\n", + compressed, bzipflag ? "bzlib" : "zlib"); } #if defined(SIGINFO) @@ -961,10 +975,14 @@ usage(void) "MnqSu" "] [-B records] [-b blocksize] [-d density]\n" "\t%s [-e inode#,inode#,...] [-E file] [-f file] [-h level] " +#ifdef HAVE_BZLIB + "[-j zlevel] " +#endif + "\n\t%s " #ifdef USE_QFA "[-Q file] " #endif - "\n\t%s [-s feet] [-T date] " + "[-s feet] [-T date] " #ifdef HAVE_ZLIB "[-z zlevel] " #endif diff --git a/dump/tape.c b/dump/tape.c index 5e79fd2..8d8933f 100644 --- a/dump/tape.c +++ b/dump/tape.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: tape.c,v 1.53 2001/07/20 11:02:45 stelian Exp $"; + "$Id: tape.c,v 1.54 2001/08/16 15:24:21 stelian Exp $"; #endif /* not lint */ #include @@ -95,6 +95,10 @@ int write(), read(); #include #endif /* HAVE_ZLIB */ +#ifdef HAVE_BZLIB +#include +#endif /* HAVE_BZLIB */ + #include "dump.h" int writesize; /* size of malloc()ed buffer for tape */ @@ -1017,11 +1021,14 @@ doslave(int cmd, int slave_number, int first) int nextslave, size, eot_count, bufsize; volatile int wrote = 0; char *buffer; -#ifdef HAVE_ZLIB +#if defined(HAVE_ZLIB) || defined(HAVE_BZLIB) struct tapebuf *comp_buf = NULL; int compresult, do_compress = !first; unsigned long worklen; -#endif /* HAVE_ZLIB */ +#ifdef HAVE_BZLIB + unsigned int worklen2; +#endif +#endif /* HAVE_ZLIB || HAVE_BZLIB */ struct slave_results returns; #ifdef __linux__ errcode_t retval; @@ -1053,15 +1060,18 @@ doslave(int cmd, int slave_number, int first) quit("master/slave protocol botched - didn't get pid of next slave.\n"); } -#ifdef HAVE_ZLIB +#if defined(HAVE_ZLIB) || defined(HAVE_BZLIB) /* if we're doing a compressed dump, allocate the compress buffer */ if (compressed) { comp_buf = malloc(sizeof(struct tapebuf) + TP_BSIZE + writesize); if (comp_buf == NULL) quit("couldn't allocate a compress buffer.\n"); - comp_buf->flags = 0; + if (bzipflag) + comp_buf->flags = COMPRESS_BZLIB; + else + comp_buf->flags = COMPRESS_ZLIB; } -#endif /* HAVE_ZLIB */ +#endif /* HAVE_ZLIB || HAVE_BZLIB */ /* * Get list of blocks to dump, read the blocks into tape buffer @@ -1090,7 +1100,7 @@ doslave(int cmd, int slave_number, int first) bufsize = writesize; /* length to write */ returns.clen = returns.unclen = bufsize; -#ifdef HAVE_ZLIB +#if defined(HAVE_ZLIB) || defined(HAVE_BZLIB) /* * When writing a compressed dump, each block except * the first one on each tape is written @@ -1107,9 +1117,38 @@ doslave(int cmd, int slave_number, int first) if (compressed && do_compress) { comp_buf->length = bufsize; worklen = TP_BSIZE + writesize; - compresult = compress2(comp_buf->buf, &worklen, - (char *)slp->tblock[0], writesize, compressed); - if (compresult == Z_OK && worklen <= (writesize - 16)) { +#ifdef HAVE_ZLIB + if (!bzipflag) { + compresult = compress2(comp_buf->buf, + &worklen, + (char *)slp->tblock[0], + writesize, + compressed); + if (compresult == Z_OK) + compresult = 1; + else + compresult = 0; + } +#endif /* HAVE_ZLIB */ +#ifdef HAVE_BZLIB + if (bzipflag) { + worklen2 = worklen; + compresult = BZ2_bzBuffToBuffCompress( + comp_buf->buf, + &worklen2, + (char *)slp->tblock[0], + writesize, + compressed, + 0, 30); + worklen = worklen2; + if (compresult == BZ_OK) + compresult = 1; + else + compresult = 0; + } + +#endif /* HAVE_BZLIB */ + if (compresult && worklen <= (writesize - 16)) { /* write the compressed buffer */ comp_buf->length = worklen; comp_buf->compressed = 1; @@ -1128,7 +1167,7 @@ doslave(int cmd, int slave_number, int first) } /* compress the remaining blocks if we're compressing */ do_compress = compressed; -#endif /* HAVE_ZLIB */ +#endif /* HAVE_ZLIB || HAVE_BZLIB */ if (sigsetjmp(jmpbuf, 1) == 0) { ready = 1; diff --git a/restore/Makefile.in b/restore/Makefile.in index 527e910..3f2ed45 100644 --- a/restore/Makefile.in +++ b/restore/Makefile.in @@ -1,4 +1,4 @@ -# $Id: Makefile.in,v 1.8 2001/04/12 16:03:30 stelian Exp $ +# $Id: Makefile.in,v 1.9 2001/08/16 15:24:21 stelian Exp $ top_srcdir= @top_srcdir@ srcdir= @srcdir@ @@ -7,7 +7,7 @@ srcdir= @srcdir@ CFLAGS= @CCOPTS@ -pipe $(OPT) $(DEFS) $(GINC) $(INC) @RESTOREDEBUG@ LDFLAGS:= $(LDFLAGS) @STATIC@ -LIBS= $(GLIBS) -le2p @READLINE@ @ZLIB@ +LIBS= $(GLIBS) -le2p @READLINE@ @ZLIB@ @BZLIB@ DEPLIBS= ../compat/lib/libcompat.a PROG= restore diff --git a/restore/tape.c b/restore/tape.c index 8864e2a..fb5c816 100644 --- a/restore/tape.c +++ b/restore/tape.c @@ -46,7 +46,7 @@ #ifndef lint static const char rcsid[] = - "$Id: tape.c,v 1.45 2001/07/20 09:01:46 stelian Exp $"; + "$Id: tape.c,v 1.46 2001/08/16 15:24:22 stelian Exp $"; #endif /* not lint */ #include @@ -84,6 +84,10 @@ static const char rcsid[] = #include #endif /* HAVE_ZLIB */ +#ifdef HAVE_BZLIB +#include +#endif /* HAVE_BZLIB */ + #include "restore.h" #include "extern.h" #include "pathnames.h" @@ -102,7 +106,7 @@ static int numtrec; static char *tapebuf; /* input buffer for read */ static int bufsize; /* buffer size without prefix */ static char *tbufptr = NULL; /* active tape buffer */ -#ifdef HAVE_ZLIB +#if defined(HAVE_ZLIB) || defined(HAVE_BZLIB) static char *comprbuf; /* uncompress work buf */ static size_t comprlen; /* size including prefix */ #endif @@ -148,7 +152,7 @@ static void xtrmapskip __P((char *, size_t)); static void xtrskip __P((char *, size_t)); static void setmagtapein __P((void)); -#ifdef HAVE_ZLIB +#if defined(HAVE_ZLIB) || defined(HAVE_BZLIB) static void newcomprbuf __P((int)); static void readtape_set __P((char *)); static void readtape_uncompr __P((char *)); @@ -235,7 +239,7 @@ newtapebuf(long size) tapebufsize = size; } -#ifdef HAVE_ZLIB +#if defined(HAVE_ZLIB) || defined(HAVE_BZLIB) static void newcomprbuf(int size) { @@ -249,7 +253,7 @@ newcomprbuf(int size) if (comprbuf == NULL) errx(1, "Cannot allocate space for decompress buffer"); } -#endif /* HAVE_ZLIB */ +#endif /* HAVE_ZLIB || HAVE_BZLIB */ /* * Verify that the tape drive can be accessed and @@ -298,7 +302,7 @@ setup(void) if (zflag) { fprintf(stderr, "Dump tape is compressed.\n"); -#ifdef HAVE_ZLIB +#if defined(HAVE_ZLIB) || defined(HAVE_BZLIB) newcomprbuf(ntrec); #else errx(1,"This restore version doesn't support decompression"); @@ -1295,7 +1299,7 @@ comparefile(char *name) /* NOTREACHED */ } -#ifdef HAVE_ZLIB +#if defined(HAVE_ZLIB) || defined(HAVE_BZLIB) static void (*readtape_func)(char *) = readtape_set; /* @@ -1328,7 +1332,7 @@ readtape_set(char *buf) readtape(buf); } -#endif /* HAVE_ZLIB */ +#endif /* HAVE_ZLIB || HAVE_BZLIB */ /* * This is the original readtape(), it's used for reading uncompressed input. @@ -1336,7 +1340,7 @@ readtape_set(char *buf) * Handle read errors, and end of media. */ static void -#ifdef HAVE_ZLIB +#if defined(HAVE_ZLIB) || defined(HAVE_BZLIB) readtape_uncompr(char *buf) #else readtape(char *buf) @@ -1460,7 +1464,7 @@ getmore: tpblksread++; } -#ifdef HAVE_ZLIB +#if defined(HAVE_ZLIB) || defined(HAVE_BZLIB) /* * Read a compressed format block from a file or pipe and uncompress it. @@ -1646,6 +1650,9 @@ decompress_tapebuf(struct tapebuf *tpbin, int readsize) /* zflag gets set in setup() from the dump header */ int cresult, blocklen; unsigned long worklen; +#ifdef HAVE_BZLIB + unsigned int worklen2; +#endif char *output = NULL,*reason = NULL, *lengtherr = NULL; /* build a length error message */ @@ -1657,41 +1664,88 @@ decompress_tapebuf(struct tapebuf *tpbin, int readsize) lengtherr = "long"; worklen = comprlen; - cresult = Z_OK; + cresult = 1; if (tpbin->compressed) { /* uncompress whatever we read, if it fails, complain later */ - cresult = uncompress(comprbuf, &worklen, tpbin->buf, blocklen); - output = comprbuf; + if (tpbin->flags == COMPRESS_ZLIB) { +#ifndef HAVE_ZLIB + errx(1,"This restore version doesn't support zlib decompression"); +#else + cresult = uncompress(comprbuf, &worklen, + tpbin->buf, blocklen); + output = comprbuf; + switch (cresult) { + case Z_OK: + break; + case Z_MEM_ERROR: + reason = "not enough memory"; + break; + case Z_BUF_ERROR: + reason = "buffer too small"; + break; + case Z_DATA_ERROR: + reason = "data error"; + break; + default: + reason = "unknown"; + } + if (cresult == Z_OK) + cresult = 1; + else + cresult = 0; +#endif /* HAVE_ZLIB */ + } + if (tpbin->flags == COMPRESS_BZLIB) { +#ifndef HAVE_BZLIB + errx(1,"This restore version doesn't support bzlib decompression"); +#else + worklen2 = worklen; + cresult = BZ2_bzBuffToBuffDecompress( + comprbuf, &worklen2, + tpbin->buf, blocklen, 0, 0); + worklen = worklen2; + output = comprbuf; + switch (cresult) { + case BZ_OK: + break; + case BZ_MEM_ERROR: + reason = "not enough memory"; + break; + case BZ_OUTBUFF_FULL: + reason = "buffer too small"; + break; + case BZ_DATA_ERROR: + case BZ_DATA_ERROR_MAGIC: + case BZ_UNEXPECTED_EOF: + reason = "data error"; + break; + default: + reason = "unknown"; + } + if (cresult == BZ_OK) + cresult = 1; + else + cresult = 0; +#endif /* HAVE_BZLIB */ + } } else { output = tpbin->buf; worklen = blocklen; } - switch (cresult) { - case Z_OK: - numtrec = worklen / TP_BSIZE; - if (worklen % TP_BSIZE != 0) - reason = "length mismatch"; - break; - case Z_MEM_ERROR: - reason = "not enough memory"; - break; - case Z_BUF_ERROR: - reason = "buffer too small"; - break; - case Z_DATA_ERROR: - reason = "data error"; - break; - default: - reason = "unknown"; - } /*switch */ + if (cresult) { + numtrec = worklen / TP_BSIZE; + if (worklen % TP_BSIZE != 0) + reason = "length mismatch"; + } if (reason) { if (lengtherr) fprintf(stderr, "%s compressed block: %d expected: %d\n", lengtherr, readsize, tpbin->length + PREFIXSIZE); fprintf(stderr, "decompression error, block %ld: %s\n", tpblksread+1, reason); - if (cresult != Z_OK) output = NULL; + if (!cresult) + output = NULL; } return output; } @@ -1719,7 +1773,7 @@ msg_read_error(char *m) break; } } -#endif /* HAVE_ZLIB */ +#endif /* HAVE_ZLIB || HAVE_BZLIB */ /* * Read the first block and get the blocksize from it. Test -- 2.39.2 From 1df5c692513d8067e0892398e1301b7eb8bba2a1 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Fri, 17 Aug 2001 09:55:09 +0000 Subject: [PATCH 06/16] Fixed a overflow problem in dump (LFS) --- CHANGES | 6 +++++- dump/traverse.c | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index dccc4ed..dba3572 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.134 2001/08/16 15:24:21 stelian Exp $ +$Id: CHANGES,v 1.135 2001/08/17 09:55:09 stelian Exp $ Changes between versions 0.4b23 and 0.4b24 (released ?????????????) =================================================================== @@ -27,6 +27,10 @@ Changes between versions 0.4b23 and 0.4b24 (released ?????????????) the tape format of a bzip2 dump is not compatible with the original BSD tape format. +7. Fixed a overflow problem in dump corrupting the dump when + very large files were encountered. Thanks to Vladimir Nadvornik + for the bug report. + Changes between versions 0.4b22 and 0.4b23 (released July 20, 2001) =================================================================== diff --git a/dump/traverse.c b/dump/traverse.c index a8ca3a4..975f6f8 100644 --- a/dump/traverse.c +++ b/dump/traverse.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: traverse.c,v 1.37 2001/07/19 09:49:35 stelian Exp $"; + "$Id: traverse.c,v 1.38 2001/08/17 09:55:09 stelian Exp $"; #endif /* not lint */ #include @@ -898,8 +898,8 @@ dumpino(struct dinode *dp, dump_ino_t ino) ext2fs_block_iterate2(fs, (ext2_ino_t)ino, 0, NULL, dumponeblock, (void *)&bc); /* deal with holes at the end of the inode */ - if (i_size > bc.next_block*sblock->fs_fsize) { - remaining = i_size - bc.next_block*sblock->fs_fsize; + if (i_size > ((u_quad_t)bc.next_block) * sblock->fs_fsize) { + remaining = i_size - ((u_quad_t)bc.next_block) * sblock->fs_fsize; for (i = 0; i < howmany(remaining, sblock->fs_fsize); i++) { bc.buf[bc.cnt++] = 0; if (bc.cnt == bc.max) { -- 2.39.2 From 103245b6fea8e7d77722e85ccb404ac1d928987d Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Thu, 6 Sep 2001 09:00:31 +0000 Subject: [PATCH 07/16] BLKSFBUF ioctl in dump. --- CHANGES | 8 +++++++- THANKS | 3 ++- dump/main.c | 16 ++++++++++------ dump/tape.c | 10 ++++++++-- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/CHANGES b/CHANGES index dba3572..0ede091 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.135 2001/08/17 09:55:09 stelian Exp $ +$Id: CHANGES,v 1.136 2001/09/06 09:00:31 stelian Exp $ Changes between versions 0.4b23 and 0.4b24 (released ?????????????) =================================================================== @@ -31,6 +31,12 @@ Changes between versions 0.4b23 and 0.4b24 (released ?????????????) very large files were encountered. Thanks to Vladimir Nadvornik for the bug report. +8. Added a ioctl(BLKFLSBUF) in dump which should flush the + kernel buffer/page cache before starting the dump, helping + a bit those who use dump on mounted filesystems. Thanks to + John Yu and to Theodore T'so + for this suggestion. + Changes between versions 0.4b22 and 0.4b23 (released July 20, 2001) =================================================================== diff --git a/THANKS b/THANKS index 80e2063..4e4b0f8 100644 --- a/THANKS +++ b/THANKS @@ -1,4 +1,4 @@ -$Id: THANKS,v 1.46 2001/07/18 09:50:48 stelian Exp $ +$Id: THANKS,v 1.47 2001/09/06 09:00:31 stelian Exp $ Dump and restore were written by the people of the CSRG at the University of California, Berkeley. @@ -81,4 +81,5 @@ Daniel Veillard Daniel.Veillard@imag.fr Jason Venner jason@idiom.com Christian Weisgerber naddy@mips.rhein-neckar.de Kim Yong-jun loveyou@hackerslab.org +John Yu jky@it.bu.edu Ian Zimmerman itz@speakeasy.org> diff --git a/dump/main.c b/dump/main.c index 5e9c111..722ca71 100644 --- a/dump/main.c +++ b/dump/main.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: main.c,v 1.59 2001/08/16 15:24:21 stelian Exp $"; + "$Id: main.c,v 1.60 2001/09/06 09:00:32 stelian Exp $"; #endif /* not lint */ #include @@ -60,6 +60,7 @@ static const char rcsid[] = #include #include #ifdef __linux__ +#include #ifdef HAVE_EXT2FS_EXT2_FS_H #include #else @@ -628,6 +629,14 @@ main(int argc, char *argv[]) } /* end of size estimate */ #ifdef __linux__ + if ((diskfd = OPEN(disk, O_RDONLY)) < 0) { + msg("Cannot open %s\n", disk); + msg("The ENTIRE dump is aborted.\n"); + exit(X_STARTUP); + } +#ifdef BLKFLSBUF + (void)ioctl(diskfd, BLKFLSBUF); +#endif retval = dump_fs_open(disk, &fs); if (retval) { com_err(disk, retval, "while opening filesystem"); @@ -642,11 +651,6 @@ main(int argc, char *argv[]) msg("The ENTIRE dump is aborted.\n"); exit(X_STARTUP); } - if ((diskfd = OPEN(disk, O_RDONLY)) < 0) { - msg("Cannot open %s\n", disk); - msg("The ENTIRE dump is aborted.\n"); - exit(X_STARTUP); - } /* if no user label specified, use ext2 filesystem label if available */ if (spcl.c_label[0] == '\0') { const char *lbl; diff --git a/dump/tape.c b/dump/tape.c index 8d8933f..f61fc87 100644 --- a/dump/tape.c +++ b/dump/tape.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: tape.c,v 1.54 2001/08/16 15:24:21 stelian Exp $"; + "$Id: tape.c,v 1.55 2001/09/06 09:00:32 stelian Exp $"; #endif /* not lint */ #include @@ -72,6 +72,9 @@ int write(), read(); #include #include #ifdef __linux__ +#include +#undef atomic_read /* this get wrongly defined in kernel */ + /* headers and we don't want it */ #ifdef HAVE_EXT2FS_EXT2_FS_H #include #else @@ -562,7 +565,7 @@ close_rewind(void) void rollforward(void) { - register struct req *p, *q, *prev; + register struct req *p, *q = NULL, *prev; register struct slave *tslp; int i, size, savedtapea, got; union u_spcl *ntb, *otb; @@ -1046,6 +1049,9 @@ doslave(int cmd, int slave_number, int first) if ((diskfd = OPEN(disk, O_RDONLY)) < 0) quit("slave couldn't reopen disk: %s\n", strerror(errno)); #ifdef __linux__ +#ifdef BLKFLSBUF + (void)ioctl(diskfd, BLKFLSBUF); +#endif ext2fs_close(fs); retval = dump_fs_open(disk, &fs); if (retval) -- 2.39.2 From caea5c768eb239f9b987791f0c665b10d7550741 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Wed, 12 Sep 2001 09:02:51 +0000 Subject: [PATCH 08/16] Modifications from the RedHat RPM. --- CHANGES | 7 +++++-- dump.spec | 48 +++++++++++++++++++++++++++--------------------- dump/optr.c | 3 +-- dump/tape.c | 3 +-- 4 files changed, 34 insertions(+), 27 deletions(-) diff --git a/CHANGES b/CHANGES index 0ede091..328ead1 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.136 2001/09/06 09:00:31 stelian Exp $ +$Id: CHANGES,v 1.137 2001/09/12 09:02:51 stelian Exp $ Changes between versions 0.4b23 and 0.4b24 (released ?????????????) =================================================================== @@ -36,7 +36,10 @@ Changes between versions 0.4b23 and 0.4b24 (released ?????????????) a bit those who use dump on mounted filesystems. Thanks to John Yu and to Theodore T'so for this suggestion. - + +9. Updated the RPM spec file following the RedHat changes + (dynamically linked binaries now in /usr/sbin etc). + Changes between versions 0.4b22 and 0.4b23 (released July 20, 2001) =================================================================== diff --git a/dump.spec b/dump.spec index bc4893f..e7d4a25 100644 --- a/dump.spec +++ b/dump.spec @@ -9,18 +9,18 @@ Release: 1 License: BSD Group: Applications/Archiving Source: http://download.sourceforge.net/dump/dump-%{version}.tar.gz -Requires: rmt BuildPrereq: e2fsprogs-devel, libtermcap-devel, readline-devel +Requires: rmt BuildRoot: %{_tmppath}/%{name}-root %description -The dump package contains both dump and restore. Dump examines files in -a filesystem, determines which ones need to be backed up, and copies -those files to a specified disk, tape or other storage medium. The -restore command performs the inverse function of dump; it can restore a -full backup of a filesystem. Subsequent incremental backups can then be -layered on top of the full backup. Single files and directory subtrees -may also be restored from full or partial backups. +The dump package contains both dump and restore. Dump examines files +in a filesystem, determines which ones need to be backed up, and +copies those files to a specified disk, tape, or other storage medium. +The restore command performs the inverse function of dump; it can +restore a full backup of a filesystem. Subsequent incremental backups +can then be layered on top of the full backup. Single files and +directory subtrees may also be restored from full or partial backups. Install dump if you need a system for both backing up filesystems and restoring filesystems after backups. @@ -32,25 +32,25 @@ Group: Applications/Archiving %description -n rmt The rmt utility provides remote access to tape devices for programs like dump (a filesystem backup program), restore (a program for -restoring files from a backup) and tar (an archiving program). +restoring files from a backup), and tar (an archiving program). %package -n dump-static Summary: Statically linked versions of dump and restore. Group: Applications/Archiving %description -n dump-static -The dump package contains both dump and restore. Dump examines files in +The dump package contains both dump and restore. Dump examines files in a filesystem, determines which ones need to be backed up, and copies -those files to a specified disk, tape or other storage medium. The +those files to a specified disk, tape, or other storage medium. The restore command performs the inverse function of dump; it can restore a -full backup of a filesystem. Subsequent incremental backups can then be -layered on top of the full backup. Single files and directory subtrees +full backup of a filesystem. Subsequent incremental backups can then be +layered on top of the full backup. Single files and directory subtrees may also be restored from full or partial backups. Install dump if you need a system for both backing up filesystems and restoring filesystems after backups. -This packages contains statically linked versions of dump and restore. +This package contains statically linked versions of dump and restore. %prep %setup -q @@ -80,12 +80,12 @@ mkdir -p %{buildroot}%{_sbindir} mkdir -p %{buildroot}%{_mandir}/man8 %makeinstall SBINDIR=%{buildroot}%{_sbindir} MANDIR=%{buildroot}%{_mandir}/man8 BINOWNER=$(id -un) BINGRP=$(id -gn) MANOWNER=$(id -un) MANGRP=$(id -gn) +mkdir -p $RPM_BUILD_ROOT/usr/sbin cp dump/dump.static %{buildroot}%{_sbindir} cp restore/restore.static %{buildroot}%{_sbindir} -{ cd %{buildroot} - strip .%{_sbindir}/* || : +pushd $RPM_BUILD_ROOT ln -sf dump .%{_sbindir}/rdump ln -sf dump.static .%{_sbindir}/rdump.static ln -sf restore .%{_sbindir}/rrestore @@ -94,7 +94,13 @@ cp restore/restore.static %{buildroot}%{_sbindir} mkdir -p .%{_sysconfdir} > .%{_sysconfdir}/dumpdates ln -sf ..%{_sbindir}/rmt .%{_sysconfdir}/rmt -} + # quick workaround :) + mv sbin/* usr/sbin/ + mv usr/sbin/*static sbin/ + mv usr/sbin/rmt sbin/ + # somehow, rpm didn't strip these... + strip usr/sbin/* sbin/* || : +popd %clean rm -rf %{buildroot} @@ -104,10 +110,10 @@ rm -rf %{buildroot} %doc CHANGES COPYRIGHT KNOWNBUGS MAINTAINERS README REPORTING-BUGS THANKS TODO %doc dump.lsm %attr(0664,root,disk) %config(noreplace) %{_sysconfdir}/dumpdates -%attr(0755,root,root) %{_sbindir}/dump -%{_sbindir}/rdump -%attr(0755,root,root) %{_sbindir}/restore -%{_sbindir}/rrestore +%attr(0755,root,root) /usr/sbin/dump +/usr/sbin/rdump +%attr(0755,root,root) /usr/sbin/restore +/usr/sbin/rrestore %{_mandir}/man8/dump.* %{_mandir}/man8/rdump.* %{_mandir}/man8/restore.* diff --git a/dump/optr.c b/dump/optr.c index cd98e66..56e1f34 100644 --- a/dump/optr.c +++ b/dump/optr.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: optr.c,v 1.26 2001/08/16 09:37:59 stelian Exp $"; + "$Id: optr.c,v 1.27 2001/09/12 09:02:51 stelian Exp $"; #endif /* not lint */ #include @@ -70,7 +70,6 @@ static const char rcsid[] = #include #include #include -#include #endif #include "dump.h" diff --git a/dump/tape.c b/dump/tape.c index f61fc87..644ed8a 100644 --- a/dump/tape.c +++ b/dump/tape.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: tape.c,v 1.55 2001/09/06 09:00:32 stelian Exp $"; + "$Id: tape.c,v 1.56 2001/09/12 09:02:51 stelian Exp $"; #endif /* not lint */ #include @@ -68,7 +68,6 @@ int write(), read(); #endif #include #include -#include #include #include #ifdef __linux__ -- 2.39.2 From 8b7882a833092b5974aa73e06b2e55bb9d1a9e99 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Wed, 12 Sep 2001 10:21:48 +0000 Subject: [PATCH 09/16] 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 From 68da8d858566324065630c459d3a6322132e279e Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Wed, 12 Sep 2001 12:40:07 +0000 Subject: [PATCH 10/16] Prepare for release 0.4b24. --- CHANGES | 6 +++--- MCONFIG.in | 4 ++-- dump.lsm | 6 +++--- dump.spec | 5 ++++- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index 3906dbb..1d37360 100644 --- a/CHANGES +++ b/CHANGES @@ -1,7 +1,7 @@ -$Id: CHANGES,v 1.138 2001/09/12 10:21:48 stelian Exp $ +$Id: CHANGES,v 1.139 2001/09/12 12:40:07 stelian Exp $ -Changes between versions 0.4b23 and 0.4b24 (released ?????????????) -=================================================================== +Changes between versions 0.4b23 and 0.4b24 (released September 12, 2001) +======================================================================== 1. Fixed the permissions of a newly created QFA file by dump. diff --git a/MCONFIG.in b/MCONFIG.in index 23bce9c..a7143cc 100644 --- a/MCONFIG.in +++ b/MCONFIG.in @@ -2,8 +2,8 @@ VPATH= $(srcdir) top_builddir= @top_builddir@ -VERSION= 0.4b23 -DATE= July 20, 2001 +VERSION= 0.4b24 +DATE= September 12, 2001 AR= @AR@ CC= @CC@ diff --git a/dump.lsm b/dump.lsm index f34aa37..ba5a245 100644 --- a/dump.lsm +++ b/dump.lsm @@ -1,13 +1,13 @@ Begin3 Title: dump and restore for Ext2fs -Version: 0.4b23 -Entered-date: 20JUL01 +Version: 0.4b24 +Entered-date: 12SEP01 Description: Port of the 4.4BSD dump and restore backup suite Keywords: backup, filesystem, Ext2fs Author: University of California, Berkeley Maintained-by: pop@noos.fr (Stelian Pop) Primary-site: http://dump.sourceforge.net/ - 135kB dump-0.4b23.tar.gz + 135kB dump-0.4b24.tar.gz 677 dump.lsm Original-site: ftp.freebsd.org /pub/bsd-sources/4.4BSD-Lite2/sbin dump/* diff --git a/dump.spec b/dump.spec index 02bce2f..483ebe9 100644 --- a/dump.spec +++ b/dump.spec @@ -4,7 +4,7 @@ Summary: Programs for backing up and restoring ext2/ext3 filesystems. Name: dump -Version: 0.4b23 +Version: 0.4b24 Release: 1 License: BSD Group: Applications/Archiving @@ -133,6 +133,9 @@ rm -rf %{buildroot} %{_sbindir}/rrestore.static %changelog +* Wed Sep 12 2001 Stelian Pop +- dump 0.4b24 released, first packaging. + * Fri Jul 20 2001 Stelian Pop - dump 0.4b23 released, first packaging. -- 2.39.2 From d37187a4063b466c8fec3cfeb3647284da58c65d Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Tue, 2 Oct 2001 09:32:54 +0000 Subject: [PATCH 11/16] Added howto from Patrick Walsh --- examples/howto/ultra-mini-howto | 244 ++++++++++++++++++++++++++++++++ 1 file changed, 244 insertions(+) create mode 100644 examples/howto/ultra-mini-howto diff --git a/examples/howto/ultra-mini-howto b/examples/howto/ultra-mini-howto new file mode 100644 index 0000000..6c2c8ab --- /dev/null +++ b/examples/howto/ultra-mini-howto @@ -0,0 +1,244 @@ +Stelian, + + I just got dump running on my system backing up a handful of unix +servers and at the end of it I wrote a quick and dirty document that lays +out the answers to some of the questions that I had. I don't want to +maintain it or get a flood of e-mail from people asking for help on it, so I +signed it, but intentionally didn't put an e-mail address. + + You are welcome to make this prettier, totally discard it, or put it up +on the web page. I hope it is accurate and relieves some of the common +questions from the list. + +..Patrick + + + + +Dump/Restore Ultra-Mini-FAQ + +Disclaimer: I am not an expert in dump/restore. In fact, +I'm a newbie. But I've been picking things up as I +implement it here and I wanted to pass some of those +things along in the form of a very basic HOWTO. + +-Patrick Walsh + +1) Introduction/ Non-rewinding device +2) Dump command line +3) Sending 2 or more filesystems to a tape +4) Compressing dumps on the fly +5) The "nodump" file and directory attribute. +6) Restoring your dumps (including compressed). +7) How to confirm a backup +8) Example backup script + + 1) Introduction/ Non-rewinding device + +You use dump to backup to a file or a tape device. If +you're backing up to a tape device, then the first thing +you need to understand is that there are two devices +that refer to your tape drive. There is the "rewinding" +device and the "non-rewinding" device. + +I wish I could tell you an easy way to figure out what +your device names are, but I don't know one. On my +local box I had a /dev/tape device that linked to +/dev/st0. It turns out that /dev/st0 is my "rewinding" +tape drive. If I write to this device it will always +rewind before starting to write. This means that if +you try to dump two filesystems, only the second one +will be stored. If your tape device is /dev/st0, like +mine, then your non-rewinding tape device is probably +/dev/nst0. + +Anyway, through the rest of this I will refer to $TAPE +and $RWTAPE. $TAPE is the non-rewinding device (in my +case /dev/nst0) and $RWTAPE is the rewinding tape (in my +case /dev/st0 and /dev/tape). $FS is the filesystem you +are backing up, such as /dev/hda1. + + 2) What options should I use? + +Use the man page to figure out what options to send +to dump. I use "dump 0uanf $TAPE $FS". + + u=update /etc/dumpdates after a successful dump + a=auto-size -- bypass all tape length calculations and + write until eof + n=notify 'operators' group when dump needs attention + f=backup to file or device specified, or - for stdout + + 3) You want to send two or more filesystems to the tape. + +OK, rewind using the mt command, then dump multiple times +to the non-rewinding device, and you're done: + +mt -f $TAPE rewind +dump 0uanf $TAPE $FS1 +dump 0uanf $TAPE $FS2 +etc. + +Check the man page of mt if you want to know how to eject +the tape or retension it or anything. + + 4) You want to compress your dumps on the fly. No +problem. Send your backup to STDOUT and manipulate it +from there. It's easier if you're sending your output to +the hard drive: + +dump 0uanf - $FS | gzip -c > /backup/outfile.dump.gz + +You want that to be written to the tape on the fly? Try +this: + +mt -f $TAPE rewind +dump 0uanf - $FS |gzip -c |dd if=- of=$TAPE + +[ You can also use the -z or -J options of dump in the + recent versions to enable internal compression - stelian ] + + 5) You read the man page and you're wondering what the +heck a "nodump" flag is. For example, how can you get +dump to stop backing up /tmp or ~/.netscape/cache. You +have two options: either exclude the inode in your dump +command, or flag the files and directories with the +"nodump" flag. To flag /tmp, for example, do this: + +chattr -R +d /tmp + +Want more details? Try 'man chattr' and 'man lsattr'. + + 6) You want to know how to restore your backup. + +Read the restore man page. But barring that, the easy way +is to use restore in interactive mode. If you have three +filesystems on one tape and you want to restore files from +the second one, you need to do this: + +mt -f $TAPE rewind +mt -f $TAPE fsf 1 # skip forward one file +restore -if $TAPE + +OK, suppose now that you used the commands in section 4 to +compress the dump file before it was written to disk. Use +this command: + +mt -f $TAPE rewind +mt -f $TAPE fsf 1 +dd if=$TAPE of=- |gzip -dc |restore -rf - + +Obviously if you dumped to a file instead of a tape it is +much easier: + +gzip -dc $filename |restore -rf - + + 7) How to confirm your backup + + Check out the restore man page and read up on the -C option. + + 8) That about sums up my knowledge on the matter, but +I feel better having written something for other people to +look at so it doesn't take them quite so long to learn the +things I did. I've included my backup script below. +There are much better ones floating around, so go find +someone else's and use theirs if mine won't work for you +or you don't understand it. + + +#!/bin/csh +# System backup script for NARNIA + +# This is a script that will backup the entire hard drive +# to the NT server (not my choice) \\fs1. +# +# On each Sunday night, a full backup will be made +# of the hard drive and each day of the week thereafter an incremental +# backup will be made that captures only those changes since the night +# before. +# Each full backup will be sent to the local tape as well as to the +# NT machine. +# +# The files will be stored in partition-specific files with integer +# endings that specify the day of the week they were saved. Files +# with zero on the end will always be full backups. + +# Dump options: +# a=auto-size -- bypass all tape length calculations and write until eof +# f=write the backup to file or device specified or - for stdout +# n=notify operators group when dump needs attention +# u=update /etc/dumpdates after a successful dump + +# Set variables that control the script. +setenv MOUNTPOINT '/root/fs1backup' +setenv OUTDIR '/root/fs1backup/narnia' +setenv TAPE '/dev/nst0' # non-rewinding tape + +# Auto-set variable that determines level of backup. +setenv DAY `date +'%w'` + +# Mount the backup partition to /root/fs1backup +/usr/bin/smbmount \\\\fs1\\backup $MOUNTPOINT -o +"username=uname,password=pword" + +# Delete files created on this day last week +rm -f $OUTDIR/*$DAY.dump.gz + +# Do the actual backing up, one filesystem at a time. + +# /dev/hda1 = /boot +/sbin/dump $DAY'uanf' - /dev/hda1 | gzip -c >$OUTDIR/boot-$DAY.dump.gz + +# /dev/hda2 = / +/sbin/dump $DAY'uanf' - /dev/hda2 | gzip -c >$OUTDIR/root-$DAY.dump.gz + +# /dev/hda3 = /usr +/sbin/dump $DAY'uanf' - /dev/hda3 | gzip -c >$OUTDIR/usr-$DAY.dump.gz + +# /dev/hdb2 = /u1 +/sbin/dump $DAY'uanf' - /dev/hdb2 | gzip -c >$OUTDIR/u1-$DAY.dump.gz + + +# OK, presumably everything is now backed up to \\fs1. On level 0 +# dumps, lets backup to the local drive too. +if ($DAY == 0) then + mt -f $TAPE retension + foreach i ($OUTDIR/*0.dump.gz) + dd if=$i of=$TAPE + end + mt -f $TAPE rewind +endif + + +# Unmount the backup partition, not needed outside of script +umount /root/fs1backup + +# Explicitly free up the temporary variables +unsetenv DAY +unsetenv MOUNTPOINT +unsetenv OUTDIR +unsetenv TAPE + + +# RESTORE DIRECTIONS: +# If from tape: +# dd if=$TAPE of=- | gzip -dc | restore -rf - +# or dd if=$TAPE |gzip -dc |restore -rf - +# +# Note: must queue tape to proper position first. This +# is done by first rewinding then advancing to the proper +# file. The order that files are written to tape is +# *probably* 0=/boot 1=/ 2=/usr 3=/u1 +# +# Use mt to skip between them: +# mt -f $TAPE rewind +# restore -if $TAPE #now restoring /boot, probably +# mt -f $TAPE fsf 1 +# restore -if $TAPE #now restoring / +# mt -f $TAPE fsf 1 +# restore -if $TAPE #now restoring /usr +# #etc. +# +# Otherwise: +# gzip -dc $filename | restore -rf - + -- 2.39.2 From 989f348a5757083e00a3bc75a6ce8fdbf834913b Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Tue, 2 Oct 2001 09:41:24 +0000 Subject: [PATCH 12/16] Add howto. --- CHANGES | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 1d37360..755423f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,10 @@ -$Id: CHANGES,v 1.139 2001/09/12 12:40:07 stelian Exp $ +$Id: CHANGES,v 1.140 2001/10/02 09:41:24 stelian Exp $ + +Changes between versions 0.4b24 and 0.4b25 (released ??????????????????) +======================================================================== + +1. Added a mini howto from Patrick Walsh in the examples + directory. Changes between versions 0.4b23 and 0.4b24 (released September 12, 2001) ======================================================================== -- 2.39.2 From c79a759f9801fa58c7c0bc53062257a3685a19e1 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Mon, 15 Oct 2001 10:58:20 +0000 Subject: [PATCH 13/16] New version from Patrick. --- examples/howto/ultra-mini-howto | 188 ++++++++++++++++++++++---------- 1 file changed, 129 insertions(+), 59 deletions(-) diff --git a/examples/howto/ultra-mini-howto b/examples/howto/ultra-mini-howto index 6c2c8ab..a3628e5 100644 --- a/examples/howto/ultra-mini-howto +++ b/examples/howto/ultra-mini-howto @@ -1,26 +1,11 @@ -Stelian, - - I just got dump running on my system backing up a handful of unix -servers and at the end of it I wrote a quick and dirty document that lays -out the answers to some of the questions that I had. I don't want to -maintain it or get a flood of e-mail from people asking for help on it, so I -signed it, but intentionally didn't put an e-mail address. - - You are welcome to make this prettier, totally discard it, or put it up -on the web page. I hope it is accurate and relieves some of the common -questions from the list. - -..Patrick - - - - Dump/Restore Ultra-Mini-FAQ -Disclaimer: I am not an expert in dump/restore. In fact, -I'm a newbie. But I've been picking things up as I -implement it here and I wanted to pass some of those -things along in the form of a very basic HOWTO. +Document v1.1 + +Disclaimer: I am not an expert in dump/restore. In +fact, I'm a newbie. But I've been picking things up as +I implement it here and I wanted to pass some of those +things along in the form of a very basic FAQ. -Patrick Walsh @@ -30,16 +15,18 @@ things along in the form of a very basic HOWTO. 4) Compressing dumps on the fly 5) The "nodump" file and directory attribute. 6) Restoring your dumps (including compressed). -7) How to confirm a backup -8) Example backup script +7) How to confirm a backup (highly recommended) +8) What are the best buffer size options? +9) Experiencing bread, lseek, lseek2 errors. +10) Example backup script 1) Introduction/ Non-rewinding device You use dump to backup to a file or a tape device. If -you're backing up to a tape device, then the first thing -you need to understand is that there are two devices -that refer to your tape drive. There is the "rewinding" -device and the "non-rewinding" device. +you're backing up to a tape device, then the first +thing you need to understand is that there are two +devices that refer to your tape drive. There is the +"rewinding" device and the "non-rewinding" device. I wish I could tell you an easy way to figure out what your device names are, but I don't know one. On my @@ -54,9 +41,9 @@ mine, then your non-rewinding tape device is probably Anyway, through the rest of this I will refer to $TAPE and $RWTAPE. $TAPE is the non-rewinding device (in my -case /dev/nst0) and $RWTAPE is the rewinding tape (in my -case /dev/st0 and /dev/tape). $FS is the filesystem you -are backing up, such as /dev/hda1. +case /dev/nst0) and $RWTAPE is the rewinding tape (in +my case /dev/st0 and /dev/tape). $FS is the filesystem +you are backing up, such as /dev/hda1. 2) What options should I use? @@ -64,33 +51,33 @@ Use the man page to figure out what options to send to dump. I use "dump 0uanf $TAPE $FS". u=update /etc/dumpdates after a successful dump - a=auto-size -- bypass all tape length calculations and - write until eof + a=auto-size -- bypass all tape length calculations + and write until eof n=notify 'operators' group when dump needs attention f=backup to file or device specified, or - for stdout - 3) You want to send two or more filesystems to the tape. + 3) You want to send two or more filesystems to tape. -OK, rewind using the mt command, then dump multiple times -to the non-rewinding device, and you're done: +OK, rewind using the mt command, then dump multiple +times to the non-rewinding device, and you're done: mt -f $TAPE rewind dump 0uanf $TAPE $FS1 dump 0uanf $TAPE $FS2 etc. -Check the man page of mt if you want to know how to eject -the tape or retension it or anything. +Check the man page of mt if you want to know how to +eject the tape or retension it or anything. 4) You want to compress your dumps on the fly. No problem. Send your backup to STDOUT and manipulate it -from there. It's easier if you're sending your output to -the hard drive: +from there. It's easier if you're sending your output +to the hard drive: dump 0uanf - $FS | gzip -c > /backup/outfile.dump.gz -You want that to be written to the tape on the fly? Try -this: +You want that to be written to the tape on the fly? +Try this: mt -f $TAPE rewind dump 0uanf - $FS |gzip -c |dd if=- of=$TAPE @@ -111,39 +98,120 @@ Want more details? Try 'man chattr' and 'man lsattr'. 6) You want to know how to restore your backup. -Read the restore man page. But barring that, the easy way -is to use restore in interactive mode. If you have three -filesystems on one tape and you want to restore files from -the second one, you need to do this: +Read the restore man page. But barring that, the easy +way is to use restore in interactive mode. If you have +three filesystems on one tape and you want to restore +files from the second one, you need to do this: mt -f $TAPE rewind mt -f $TAPE fsf 1 # skip forward one file restore -if $TAPE -OK, suppose now that you used the commands in section 4 to -compress the dump file before it was written to disk. Use -this command: +OK, suppose now that you used the commands in section 4 +to compress the dump file before it was written to +disk. Use this command: mt -f $TAPE rewind mt -f $TAPE fsf 1 dd if=$TAPE of=- |gzip -dc |restore -rf - -Obviously if you dumped to a file instead of a tape it is -much easier: +Obviously if you dumped to a file instead of a tape it +is much easier: gzip -dc $filename |restore -rf - 7) How to confirm your backup - Check out the restore man page and read up on the -C option. - - 8) That about sums up my knowledge on the matter, but -I feel better having written something for other people to -look at so it doesn't take them quite so long to learn the -things I did. I've included my backup script below. -There are much better ones floating around, so go find -someone else's and use theirs if mine won't work for you -or you don't understand it. + Check out the restore man page and read up on the -C +option. + + 8) What are the best buffer size options? + + Bernhard R. Erdmann answered this question on the +dump-users mailing list. His excellent response +follows: + +>> While I was doing google searches, there seems to be +>> an issue regarding the default buffer size writing +>> to tape. According to some, the default buffer size +>> of 512 can harm modern drives. I have a Seagate +>> DDS3 unit and am wondering what the best mt/dump +>> options are. I am using datacompression in +>> hardware. Should I go with a large buffer (mt +>> setblk 10240) or variable (mt setblk 0). If I +>> change these sizes, does dump need to know about it? +> +>Dump/restore uses a default blocksize of 10 KB. You +>can change it with the "-b" option or use dd for +>(re-)blocking. +> +>dump 0ab 32 / +>dump 0af - / | dd obs=32k of=$TAPE +>ssh host "/sbin/dump 0af - /" | dd obs=32k of=$TAPE +>restore rb 32 +>dd ibs=32k if=$TAPE | restore rf - +>ssh host "dd if=/dev/nst0 ibs=32k" | restore rf - +> +>Personally, I'd stick with variable blocksize on the +>drive and use 32 KB as the application's blocksize as +>Amanda uses that size, too. +> +>Rumours told using 64 KB or 128 KB blocksize yields to +>increase performance (maybe on the mtx list from an +>Arkeia developer) didn't had any effects in my own +>tests with blocksizes ranging from 10 to 64 KB some +>months ago on a DDS-2 drive. +> +>Regarding tape drive performance at different block +>sizes you may want to read +>http://www.rs6000.ibm.com/support/micro/tapewhdr.html#Header_133 +> +>- Block size, can effect the time for backup/restore. +>Using large blocksizes may improve performance. Using +>small block sizes can increase system overhead but +>before changing to a large blocksize it is necessary +>to be sure the user application supports the larger +>blocksize chosen. +>- Very long restore times due to blocksize. If a +>backup is done with a fixed block length then the +>restore should be done with the same fixed block +>length. If a backup is done with a fixed block length +>and the restore is done with variable block length, +>the restore may work successfully but it may take many +>more hours to restore than it took to back up the +>data. The reason for this is that when AIX reads fixed +>block length data in variable block mode, a check +>condition is issued by the tape drive on every read. +>AIX must interpret every check condition and determine +>the proper action to take. This often will put the +>tape drive into a mode of reading that will require +>the tape drive to stop tape motion, rewind the tape +>some distance, then start reading again. This will +>reduce the life expectancy of the tape and increase +>the time it takes to backup data. + + 9) Experiencing bread, lseek, and lseek2 errors. + + These errors are caused by inodes being changed +during the backup. This is normal because dump and +the Linux kernel are both acessing the filesystem +and there is no consistence checking. By "calming" +the system (killing unnecessary processes), you +decrease the likelihood of having these +errors. Read up on the bug on Sourcefourge: + +http://sourceforge.net/tracker/index.php?func=detail&aid=204909&group_id=1306&atid=101306 + +Note that the only "real" solution to this problem +is to dump a unmounted filesystem or use a filesystem +snapshot feature (like in LVM). + + 10) That about sums up my knowledge on the matter, but +I feel better having written something for other peopleto look at so it doesn't take them quite so long to +learn the things I did. I've included my backup script +below. There are much better ones floating around, so +go find someone else's and use theirs if mine won't +work for you or you don't understand it. #!/bin/csh @@ -242,3 +310,5 @@ unsetenv TAPE # Otherwise: # gzip -dc $filename | restore -rf - + + -- 2.39.2 From 7ae7e903ec0c23946c686440cc586d5b77a4236b Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Sat, 10 Nov 2001 23:50:59 +0000 Subject: [PATCH 14/16] Minor manpages syntax corrections. --- dump/dump.8.in | 3 ++- restore/restore.8.in | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dump/dump.8.in b/dump/dump.8.in index 129001c..b3171ca 100644 --- a/dump/dump.8.in +++ b/dump/dump.8.in @@ -30,7 +30,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: dump.8.in,v 1.32 2001/08/16 15:24:21 stelian Exp $ +.\" $Id: dump.8.in,v 1.33 2001/11/10 23:50:59 stelian Exp $ .\" .Dd __DATE__ .Dt DUMP 8 @@ -486,6 +486,7 @@ remote shell command to use when doing remote backups (rsh, ssh etc.). If this variable is not set, .Xr rcmd 3 will be used, but only root will be able to do remote backups. +.El .Sh FILES .Bl -tag -width __DUMPDATES__ -compact .It Pa /dev/st0 diff --git a/restore/restore.8.in b/restore/restore.8.in index b13346a..b838b1a 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.17 2001/09/12 10:21:49 stelian Exp $ +.\" $Id: restore.8.in,v 1.18 2001/11/10 23:51:00 stelian Exp $ .\" .Dd __DATE__ .Dt RESTORE 8 @@ -569,6 +569,7 @@ remote shell command to use when doing a network restore (rsh, ssh etc.). If this variable is not set, .Xr rcmd 3 will be used, but only root will be able to do a network restore. +.El .Sh FILES .Bl -tag -width "./restoresymtable" -compact .It Pa /dev/st0 -- 2.39.2 From ec617e1df3171531a327366c08fe46f16baacd2e Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Sat, 10 Nov 2001 23:56:07 +0000 Subject: [PATCH 15/16] Script from David B. Peterson. --- examples/remote_backup_ssh/backitup | 59 +++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 examples/remote_backup_ssh/backitup diff --git a/examples/remote_backup_ssh/backitup b/examples/remote_backup_ssh/backitup new file mode 100644 index 0000000..eacdd3b --- /dev/null +++ b/examples/remote_backup_ssh/backitup @@ -0,0 +1,59 @@ +#!/bin/sh + +# +# This script will backup local drives to a remote tape drive over ssh. +# written by David B. Peterson +# +# Follow these steps before using it the first time: +# 1. Configure the env variables below, especially OPERATOR, TAPEHOST +# TAPEDEV, and FILESYSTEMS +# 2. run the following commands as root (on the machine to be backed up): +# ssh-keygen -t dsa +# cat ~/.ssh/id_dsa.pub | ssh OPERATOR@TAPEHOST 'cat - >> ~/.ssh/authorized_keys2' +# +# where OPERATOR and TAPEHOST are as you have defined below. + +# We will run under screen so you can come back to the backup, if you need to. +if [ ! "$WINDOW" ]; then + exec screen $0 + exit +fi + +# ssh-agent allows us to backup securely without entering the passphrase so +# many times. This version uses openssh v2.9 +if [ ! $SSH_AGENT_PID ]; then + echo Starting ssh-agent... + exec ssh-agent -- /bin/sh $0 + exit +fi + +OPERATOR=backup +TAPEHOST=tapehost.example.com +TAPEDEV=/dev/nst0 +RMT=/sbin/rmt +RSH='/usr/bin/ssh' +DATE=`date +%Y%m%d` +DUMP='/sbin/dump 0auf' +LOGDIR=/var/log/backup +FILESYSTEMS='hda1 hda7 hda6 hda5 hda10' + +#### config above #### +# backup FILESYSTEMS to the TAPEDEV on TAPEHOST with DUMP as OPERATOR using RSH + +export RMT RSH +mkdir -p $LOGDIR &> /dev/null +ssh-add ~/.ssh/id_dsa + +echo "Rewinding tape..." +REWIND="mt -f $TAPEDEV rewind" +$RSH $OPERATOR@$TAPEHOST $REWIND + +for FS in $FILESYSTEMS +do + $DUMP $OPERATOR@$TAPEHOST:$TAPEDEV /dev/$FS 2>&1 | tee $LOGDIR/$FS.$DATE +done + +echo "Rewinding and ejecting tape..." +OFFLINE="mt -f $TAPEDEV offline" +$RSH $OPERATOR@$TAPEHOST $OFFLINE + -- 2.39.2 From b82d31dc01e8474d503a86fbf52ddf6d74c245e6 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Sun, 11 Nov 2001 00:06:39 +0000 Subject: [PATCH 16/16] Make BREADEMAX adjustable with the -I option to dump. --- CHANGES | 13 ++++++++++++- THANKS | 5 ++++- dump/dump.8.in | 17 ++++++++++++++--- dump/dump.h | 3 ++- dump/main.c | 11 +++++++++-- dump/traverse.c | 9 ++++----- 6 files changed, 45 insertions(+), 13 deletions(-) diff --git a/CHANGES b/CHANGES index 755423f..cdb7894 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.140 2001/10/02 09:41:24 stelian Exp $ +$Id: CHANGES,v 1.141 2001/11/11 00:06:39 stelian Exp $ Changes between versions 0.4b24 and 0.4b25 (released ??????????????????) ======================================================================== @@ -6,6 +6,17 @@ Changes between versions 0.4b24 and 0.4b25 (released ??????????????????) 1. Added a mini howto from Patrick Walsh in the examples directory. +2. Minor man pages syntax corrections. Thanks to + Chris Danis for reporting the bugs. + +3. Added a script from David B. Peterson + to the examples section. It features dumping several + filesystems to a remote tape drive upon ssh. + +4. Added a patch provided by Richard Jones + which allows BRADEMAX (number of read errors tolerated by + dump) to be adjusted using the -I option. + Changes between versions 0.4b23 and 0.4b24 (released September 12, 2001) ======================================================================== diff --git a/THANKS b/THANKS index 4e4b0f8..9336679 100644 --- a/THANKS +++ b/THANKS @@ -1,4 +1,4 @@ -$Id: THANKS,v 1.47 2001/09/06 09:00:31 stelian Exp $ +$Id: THANKS,v 1.48 2001/11/11 00:06:39 stelian Exp $ Dump and restore were written by the people of the CSRG at the University of California, Berkeley. @@ -29,6 +29,7 @@ Rob Cermak cermak@ahab.rutgers.edu Isaac Chuang ike@isl.stanford.edu Rainer Clasen bj@ncc.cicely.de W. Reilly Cooley wcooley@nakedape.cc +Chris Danis screechco@home.com Abhijit Dasgupta abhijit@ans.net John R. Dennison gerdesas@users.sourceforge.net Andreas Dilger adilger@turbolinux.com @@ -44,6 +45,7 @@ Jean-Paul van der Jagt jeanpaul@dutepp0.et.tudelft.nl Helmut Jarausch jarausch@igpm.rwth-aachen.de Eric Jergensen eric@dvns.com Jeff Johnson jbj@redhat.com +Richard Jones rich@annexia.org Charles Karney karney@users.sourceforge.net Henry Katz hkatz@hkatz.dialup.access.net Klaus Kudielka kkudielk@cacofonix.nt.tuwien.ac.at @@ -60,6 +62,7 @@ Lukas Nellen L.Nellen@ThPhys.Uni-Heidelberg.DE Nuno Oliveira nuno@eq.uc.pt Brent Olson night@halcyon.com Jerry Peters gapeters@worldnet.att.net +David B. Peterson dave@toppledwagon.com Dave Platt dplatt@snulbug.mtview.ca.us Kenneth Porter shiva@well.com Graham Reed greed@users.sourceforge.net diff --git a/dump/dump.8.in b/dump/dump.8.in index b3171ca..fa0578b 100644 --- a/dump/dump.8.in +++ b/dump/dump.8.in @@ -30,7 +30,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: dump.8.in,v 1.33 2001/11/10 23:50:59 stelian Exp $ +.\" $Id: dump.8.in,v 1.34 2001/11/11 00:06:39 stelian Exp $ .\" .Dd __DATE__ .Dt DUMP 8 @@ -49,6 +49,7 @@ .Op Fl f Ar file .Op Fl F Ar script .Op Fl h Ar level +.Op Fl I Ar nr errors .Op Fl j Ar compression level .Op Fl L Ar label .Op Fl Q Ar file @@ -221,6 +222,15 @@ For security reasons, .Nm reverts back to the real user ID and the real group ID before running the script. +.It Fl I Ar nr errors +By default, +.Nm +will ignore the first 32 read errors on the file +system before asking for operator intervention. You can change this +using this flag to any value. This is useful when running +.Nm +on an active filesystem where read errors simply indicate an +inconsistency between the mapping and dumping passes. .It Fl j Ar compression level Compress every block to be written on the tape using bzlib library. This option will work only when dumping to a file or pipe or, when dumping @@ -382,7 +392,7 @@ end of tape, end of dump, tape write error, tape open error or -disk read error (if there is more than a threshold of 32). +disk read error (if there is more than a threshold of nr errors). In addition to alerting all operators implied by the .Fl n key, @@ -514,7 +524,8 @@ abnormal termination is indicated with an exit code of 3. It might be considered a bug that this version of dump can only handle ext2 filesystems. Specifically, it does not work with FAT filesystems. .Pp -Fewer than 32 read errors on the filesystem are ignored. If noticing +Fewer than 32 read errors (change this with -I) +on the filesystem are ignored. If noticing read errors is important, the output from dump can be parsed to look for lines that contain the text 'read error'. .Pp diff --git a/dump/dump.h b/dump/dump.h index 4f46fa4..5d22dbb 100644 --- a/dump/dump.h +++ b/dump/dump.h @@ -5,7 +5,7 @@ * Stelian Pop , 1999-2000 * Stelian Pop - Alcôve , 2000 * - * $Id: dump.h,v 1.32 2001/08/16 15:24:21 stelian Exp $ + * $Id: dump.h,v 1.33 2001/11/11 00:06:39 stelian Exp $ */ /*- @@ -77,6 +77,7 @@ extern int bzipflag; /* compression is done using bzlib */ extern int uflag; /* update flag */ extern int Mflag; /* multi-volume flag */ extern int qflag; /* quit on errors flag */ +extern int breademax; /* maximum number of bread errors before we quit */ extern char *eot_script; /* end of volume script fiag */ extern int diskfd; /* disk file descriptor */ extern int tapefd; /* tape file descriptor */ diff --git a/dump/main.c b/dump/main.c index 722ca71..e1d3db3 100644 --- a/dump/main.c +++ b/dump/main.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: main.c,v 1.60 2001/09/06 09:00:32 stelian Exp $"; + "$Id: main.c,v 1.61 2001/11/11 00:06:39 stelian Exp $"; #endif /* not lint */ #include @@ -107,6 +107,7 @@ int bzipflag; /* compression is done using bzlib */ int uflag; /* update flag */ int Mflag; /* multi-volume flag */ int qflag; /* quit on errors flag */ +int breademax = 32; /* maximum number of bread errors before we quit */ char *eot_script; /* end of volume script fiag */ int diskfd; /* disk file descriptor */ int tapefd; /* tape file descriptor */ @@ -236,7 +237,7 @@ main(int argc, char *argv[]) #endif /* USE_QFA */ while ((ch = getopt(argc, argv, - "0123456789aB:b:cd:e:E:f:F:h:" + "0123456789aB:b:cd:e:E:f:F:h:I:" #ifdef HAVE_BZLIB "j::" #endif @@ -333,6 +334,11 @@ main(int argc, char *argv[]) break; #endif /* HAVE_BZLIB */ + case 'I': + breademax = + numarg ("number of errors to ignore", 1L, 0L); + break; + #ifdef KERBEROS case 'k': dokerberos = 1; @@ -979,6 +985,7 @@ usage(void) "MnqSu" "] [-B records] [-b blocksize] [-d density]\n" "\t%s [-e inode#,inode#,...] [-E file] [-f file] [-h level] " + "[-I nr errors] " #ifdef HAVE_BZLIB "[-j zlevel] " #endif diff --git a/dump/traverse.c b/dump/traverse.c index 975f6f8..ffcac88 100644 --- a/dump/traverse.c +++ b/dump/traverse.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: traverse.c,v 1.38 2001/08/17 09:55:09 stelian Exp $"; + "$Id: traverse.c,v 1.39 2001/11/11 00:06:39 stelian Exp $"; #endif /* not lint */ #include @@ -1239,11 +1239,10 @@ getino(dump_ino_t inum) /* * Read a chunk of data from the disk. * Try to recover from hard errors by reading in sector sized pieces. - * Error recovery is attempted at most BREADEMAX times before seeking + * Error recovery is attempted at most breademax times before seeking * consent from the operator to continue. */ int breaderrors = 0; -#define BREADEMAX 32 void bread(daddr_t blkno, char *buf, int size) @@ -1282,9 +1281,9 @@ loop: else msg("short read error from %s: [block %d]: count=%d, got=%d\n", disk, blkno, size, cnt); - if (++breaderrors > BREADEMAX) { + if (++breaderrors > breademax) { msg("More than %d block read errors from %d\n", - BREADEMAX, disk); + breademax, disk); broadcast("DUMP IS AILING!\n"); msg("This is an unrecoverable error.\n"); if (!query("Do you want to attempt to continue?")){ -- 2.39.2