X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=client-src%2Fsendbackup-dump.c;h=b0a8ec7ec236a66bc2755f0e30c960629dc840da;hb=2627875b7d18858bc1f9f7652811e4d8c15a23eb;hp=75af415e73d850a43b7b56309d98513c643afafa;hpb=2df780bff19c457b0debb7adc29972a0bc2a5dc2;p=debian%2Famanda diff --git a/client-src/sendbackup-dump.c b/client-src/sendbackup-dump.c index 75af415..b0a8ec7 100644 --- a/client-src/sendbackup-dump.c +++ b/client-src/sendbackup-dump.c @@ -1,6 +1,6 @@ /* * Amanda, The Advanced Maryland Automatic Network Disk Archiver - * Copyright (c) 1991-1998 University of Maryland at College Park + * Copyright (c) 1991-1999 University of Maryland at College Park * All Rights Reserved. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -24,63 +24,61 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: sendbackup-dump.c,v 1.65.2.5.4.2.2.9.2.1 2005/09/20 18:13:08 jrjackson Exp $ + * $Id: sendbackup-dump.c,v 1.90 2006/07/25 18:10:07 martinea Exp $ * * send backup data using BSD dump */ +#include "amanda.h" #include "sendbackup.h" -#include "clock.h" #include "getfsent.h" +#include "clock.h" #include "version.h" -#ifdef KRB4_SECURITY -#include "sendbackup-krb4.h" -#else /* I'd tell you what this does */ -#define NAUGHTY_BITS /* but then I'd have to kill you */ -#endif - #define LEAF_AND_DIRS "sed -e \'\ns/^leaf[ \t]*[0-9]*[ \t]*\\.//\nt\n/^dir[ \t]/ {\ns/^dir[ \t]*[0-9]*[ \t]*\\.//\ns%$%/%\nt\n}\nd\n\'" -static regex_t re_table[] = { +static amregex_t re_table[] = { /* the various encodings of dump size */ /* this should also match BSDI pre-3.0's buggy dump program, that produced doubled DUMP: DUMP: messages */ - AM_SIZE_RE("DUMP: [0-9][0-9]* tape blocks", 1024), - AM_SIZE_RE("dump: Actual: [0-9][0-9]* tape blocks", 1024), + AM_SIZE_RE("DUMP: [0-9][0-9]* tape blocks", 1024, 1), + AM_SIZE_RE("dump: Actual: [0-9][0-9]* tape blocks", 1024, 1), AM_SIZE_RE("backup: There are [0-9][0-9]* tape blocks on [0-9][0-9]* tapes", - 1024), + 1024, 1), AM_SIZE_RE("backup: [0-9][0-9]* tape blocks on [0-9][0-9]* tape\\(s\\)", - 1024), + 1024, 1), AM_SIZE_RE("backup: [0-9][0-9]* 1k blocks on [0-9][0-9]* volume\\(s\\)", - 1024), + 1024, 1), AM_SIZE_RE("DUMP: [0-9][0-9]* blocks \\([0-9][0-9]*KB\\) on [0-9][0-9]* volume", - 512), - + 512, 1), AM_SIZE_RE("DUMP: [0-9][0-9]* blocks \\([0-9][0-9]*\\.[0-9][0-9]*MB\\) on [0-9][0-9]* volume", - 512), - AM_SIZE_RE("DUMP: [0-9][0-9]* blocks", 512), - AM_SIZE_RE("DUMP: [0-9][0-9]* bytes were dumped", 1), + 512, 1), + AM_SIZE_RE("DUMP: [0-9][0-9]* blocks \\([0-9][0-9]*KB\\)", + 1024, 2), + AM_SIZE_RE("DUMP: [0-9][0-9]* blocks \\([0-9][0-9]*\\.[0-9][0-9]*MB\\)", + 1048576, 2), + AM_SIZE_RE("DUMP: [0-9][0-9]* blocks", 512, 1), + AM_SIZE_RE("DUMP: [0-9][0-9]* bytes were dumped", 1, 1), /* OSF's vdump */ - AM_SIZE_RE("vdump: Dumped [0-9][0-9]* of [0-9][0-9]* bytes", 1), + AM_SIZE_RE("vdump: Dumped [0-9][0-9]* of [0-9][0-9]* bytes", 1, 1), /* DU 4.0a dump */ - AM_SIZE_RE("dump: Actual: [0-9][0-9]* blocks output to pipe", 1024), + AM_SIZE_RE("dump: Actual: [0-9][0-9]* blocks output to pipe", 1024, 1), /* DU 4.0 vdump */ - AM_SIZE_RE("dump: Dumped [0-9][0-9]* of [0-9][0-9]* bytes", 1), + AM_SIZE_RE("dump: Dumped [0-9][0-9]* of [0-9][0-9]* bytes", 1, 1), /* HPUX dump */ - AM_SIZE_RE("DUMP: [0-9][0-9]* KB actual output", 1024), + AM_SIZE_RE("DUMP: [0-9][0-9]* KB actual output", 1024, 1), /* HPUX 10.20 and above vxdump */ - AM_SIZE_RE("vxdump: [0-9][0-9]* tape blocks", 1024), + AM_SIZE_RE("vxdump: [0-9][0-9]* tape blocks", 1024, 1), /* UnixWare vxdump */ - AM_SIZE_RE("vxdump: [0-9][0-9]* blocks", 1024), + AM_SIZE_RE("vxdump: [0-9][0-9]* blocks", 1024, 1), /* SINIX vxdump */ - AM_SIZE_RE(" VXDUMP: [0-9][0-9]* blocks", 512), + AM_SIZE_RE(" VXDUMP: [0-9][0-9]* blocks", 512, 1), /* SINIX ufsdump */ - AM_SIZE_RE(" UFSDUMP: [0-9][0-9]* blocks", 512), + AM_SIZE_RE(" UFSDUMP: [0-9][0-9]* blocks", 512, 1), /* Irix 6.2 xfs dump */ - AM_SIZE_RE("xfsdump: media file size [0-9][0-9]* bytes", 1), + AM_SIZE_RE("xfsdump: media file size [0-9][0-9]* bytes", 1, 1), /* NetApp dump */ - AM_SIZE_RE("DUMP: [0-9][0-9]* KB", 1024), + AM_SIZE_RE("DUMP: [0-9][0-9]* KB", 1024, 1), /* strange dump lines */ AM_STRANGE_RE("should not happen"), @@ -91,25 +89,25 @@ static regex_t re_table[] = { /* any blank or non-strange DUMP: lines are marked as normal */ AM_NORMAL_RE("^ *DUMP:"), - AM_NORMAL_RE("^dump:"), /* OSF/1 */ - AM_NORMAL_RE("^vdump:"), /* OSF/1 */ - AM_NORMAL_RE("^ *vxdump:"), /* HPUX10 */ - AM_NORMAL_RE("^ *vxfs *vxdump:"), /* Solaris */ - AM_NORMAL_RE("^Dumping .* to stdout"), /* Solaris vxdump */ - AM_NORMAL_RE("^xfsdump:"), /* IRIX xfs */ - AM_NORMAL_RE("^ *VXDUMP:"), /* Sinix */ - AM_NORMAL_RE("^ *UFSDUMP:"), /* Sinix */ + AM_NORMAL_RE("^dump:"), /* OSF/1 */ + AM_NORMAL_RE("^vdump:"), /* OSF/1 */ + AM_NORMAL_RE("^ *vxdump:"), /* HPUX10 */ + AM_NORMAL_RE("^ *vxfs *vxdump:"), /* Solaris */ + AM_NORMAL_RE("^Dumping .* to stdout"), /* Sol vxdump */ + AM_NORMAL_RE("^xfsdump:"), /* IRIX xfs */ + AM_NORMAL_RE("^ *VXDUMP:"), /* Sinix */ + AM_NORMAL_RE("^ *UFSDUMP:"), /* Sinix */ #ifdef VDUMP /* this is for OSF/1 3.2's vdump for advfs */ - AM_NORMAL_RE("^The -s option is ignored"), /* OSF/1 */ - AM_NORMAL_RE("^path"), /* OSF/1 */ - AM_NORMAL_RE("^dev/fset"), /* OSF/1 */ - AM_NORMAL_RE("^type"), /* OSF/1 */ - AM_NORMAL_RE("^advfs id"), /* OSF/1 */ + AM_NORMAL_RE("^The -s option is ignored"), /* OSF/1 */ + AM_NORMAL_RE("^path"), /* OSF/1 */ + AM_NORMAL_RE("^dev/fset"), /* OSF/1 */ + AM_NORMAL_RE("^type"), /* OSF/1 */ + AM_NORMAL_RE("^advfs id"), /* OSF/1 */ AM_NORMAL_RE("^[A-Z][a-z][a-z] [A-Z][a-z][a-z] .[0-9] [0-9]"), /* OSF/1 */ #endif - AM_NORMAL_RE("^backup:"), /* AIX */ + AM_NORMAL_RE("^backup:"), /* AIX */ AM_NORMAL_RE("^ Use the umount command to unmount the filesystem"), AM_NORMAL_RE("^[ \t]*$"), @@ -118,75 +116,127 @@ static regex_t re_table[] = { AM_STRANGE_RE(NULL) }; -static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, indexf) - char *host; - char *disk, *amdevice; - int level, dataf, mesgf, indexf; - char *dumpdate; +static void start_backup(dle_t *dle, char *host, + int dataf, int mesgf, int indexf); +static void end_backup(dle_t *dle, int status); + +/* + * doing similar to $ dump | compression | encryption + */ + +static void +start_backup( + dle_t *dle, + char *host, + int dataf, + int mesgf, + int indexf) { - int dumpin, dumpout; + int dumpin, dumpout, compout; char *dumpkeys = NULL; char *device = NULL; char *fstype = NULL; char *cmd = NULL; + char *cmdX = NULL; char *indexcmd = NULL; char level_str[NUM_STR_SIZE]; + char *compopt = NULL; + char *encryptopt = skip_argument; + char *qdisk; + char *config; + + g_snprintf(level_str, SIZEOF(level_str), "%d", GPOINTER_TO_INT(dle->level->data)); + + qdisk = quote_string(dle->disk); + dbprintf(_("start: %s:%s lev %d\n"), host, qdisk, GPOINTER_TO_INT(dle->level->data)); + + g_fprintf(stderr, _("%s: start [%s:%s level %d]\n"), + get_pname(), host, qdisk, GPOINTER_TO_INT(dle->level->data)); + amfree(qdisk); + + /* apply client-side encryption here */ + if (dle->encrypt == ENCRYPT_CUST ) { + encpid = pipespawn(dle->clnt_encrypt, STDIN_PIPE, 0, + &compout, &dataf, &mesgf, + dle->clnt_encrypt, encryptopt, NULL); + dbprintf(_("gnutar: pid %ld: %s\n"), (long)encpid, dle->clnt_encrypt); + } else { + compout = dataf; + encpid = -1; + } + /* now do the client-side compression */ - ap_snprintf(level_str, sizeof(level_str), "%d", level); - - fprintf(stderr, "%s: start [%s:%s level %d]\n", - get_pname(), host, disk, level); - - NAUGHTY_BITS; - if(options->compress == COMPR_FAST || options->compress == COMPR_BEST) { - char *compopt = skip_argument; + if(dle->compress == COMP_FAST || dle->compress == COMP_BEST) { + compopt = skip_argument; #if defined(COMPRESS_BEST_OPT) && defined(COMPRESS_FAST_OPT) - if(options->compress == COMPR_BEST) { + if(dle->compress == COMP_BEST) { compopt = COMPRESS_BEST_OPT; } else { compopt = COMPRESS_FAST_OPT; } #endif - comppid = pipespawn(COMPRESS_PATH, STDIN_PIPE, - &dumpout, &dataf, &mesgf, + comppid = pipespawn(COMPRESS_PATH, STDIN_PIPE, 0, + &dumpout, &compout, &mesgf, COMPRESS_PATH, compopt, NULL); - dbprintf(("%s: pid %ld: %s", - debug_prefix_time("-dump"), (long)comppid, COMPRESS_PATH)); + dbprintf(_("dump: pid %ld: %s"), (long)comppid, COMPRESS_PATH); + if(compopt != skip_argument) { + dbprintf(" %s", compopt); + } + dbprintf("\n"); + } else if (dle->compress == COMP_CUST) { + compopt = skip_argument; + comppid = pipespawn(dle->compprog, STDIN_PIPE, 0, + &dumpout, &compout, &mesgf, + dle->compprog, compopt, NULL); + dbprintf(_("gnutar-cust: pid %ld: %s"), + (long)comppid, dle->compprog); if(compopt != skip_argument) { - dbprintf((" %s", compopt)); + dbprintf(" %s", compopt); } - dbprintf(("\n")); + dbprintf("\n"); } else { - dumpout = dataf; + dumpout = compout; comppid = -1; } /* invoke dump */ - device = amname_to_devname(amdevice); - fstype = amname_to_fstype(amdevice); + device = amname_to_devname(dle->device); + fstype = amname_to_fstype(dle->device); - dbprintf(("%s: dumping device '%s' with '%s'\n", - debug_prefix_time(NULL), device, fstype)); + dbprintf(_("dumping device '%s' with '%s'\n"), device, fstype); #if defined(USE_RUNDUMP) || !defined(DUMP) - cmd = vstralloc(libexecdir, "/", "rundump", versionsuffix(), NULL); + cmd = vstralloc(amlibexecdir, "/", "rundump", versionsuffix(), NULL); + cmdX = cmd; + if (g_options->config) + config = g_options->config; + else + config = "NOCONFIG"; #else cmd = stralloc(DUMP); + cmdX = skip_argument; + config = skip_argument; #endif #ifndef AIX_BACKUP /* { */ /* normal dump */ #ifdef XFSDUMP /* { */ #ifdef DUMP /* { */ - if (strcmp(amname_to_fstype(amdevice), "xfs") == 0) + if (strcmp(amname_to_fstype(dle->device), "xfs") == 0) #else /* } { */ if (1) #endif /* } */ { - char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump", + char *progname = cmd = newvstralloc(cmd, amlibexecdir, "/", "rundump", versionsuffix(), NULL); + cmdX = cmd; + if (g_options->config) + config = g_options->config; + else + config = "NOCONFIG"; + program->backup_name = XFSDUMP; program->restore_name = XFSRESTORE; @@ -198,15 +248,16 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in " | sed", " -e", " \'s/^/\\//\'", NULL); - write_tapeheader(); + info_tapeheader(dle); - start_index(options->createindex, dumpout, mesgf, indexf, indexcmd); + start_index(dle->create_index, dumpout, mesgf, indexf, indexcmd); dumpkeys = stralloc(level_str); - dumppid = pipespawn(progname, STDIN_PIPE, + dumppid = pipespawn(progname, STDIN_PIPE, 0, &dumpin, &dumpout, &mesgf, + cmdX, config, "xfsdump", - options->no_record ? "-J" : skip_argument, + !dle->record ? "-J" : skip_argument, "-F", "-l", dumpkeys, "-", @@ -217,22 +268,29 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in #endif /* } */ #ifdef VXDUMP /* { */ #ifdef DUMP - if (strcmp(amname_to_fstype(amdevice), "vxfs") == 0) + if (strcmp(amname_to_fstype(dle->device), "vxfs") == 0) #else if (1) #endif { #ifdef USE_RUNDUMP - char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump", + char *progname = cmd = newvstralloc(cmd, amlibexecdir, "/", "rundump", versionsuffix(), NULL); + cmdX = cmd; + if (g_options->config) + config = g_options->config; + else + config = "NOCONFIG"; #else char *progname = cmd = newvstralloc(cmd, VXDUMP, NULL); + cmdX = skip_argument; + config = skip_argument; #endif program->backup_name = VXDUMP; program->restore_name = VXRESTORE; dumpkeys = vstralloc(level_str, - options->no_record ? "" : "u", + !dle->record ? "" : "u", "s", "f", NULL); @@ -243,12 +301,13 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in " | ", LEAF_AND_DIRS, NULL); - write_tapeheader(); + info_tapeheader(dle); - start_index(options->createindex, dumpout, mesgf, indexf, indexcmd); + start_index(dle->create_index, dumpout, mesgf, indexf, indexcmd); - dumppid = pipespawn(progname, STDIN_PIPE, + dumppid = pipespawn(progname, STDIN_PIPE, 0, &dumpin, &dumpout, &mesgf, + cmdX, config, "vxdump", dumpkeys, "1048576", @@ -261,19 +320,24 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in #ifdef VDUMP /* { */ #ifdef DUMP - if (strcmp(amname_to_fstype(amdevice), "advfs") == 0) + if (strcmp(amname_to_fstype(dle->device), "advfs") == 0) #else if (1) #endif { - char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump", + char *progname = cmd = newvstralloc(cmd, amlibexecdir, "/", "rundump", versionsuffix(), NULL); - device = newstralloc(device, amname_to_dirname(amdevice)); + cmdX = cmd; + if (g_options->config) + config = g_options->config; + else + config = "NOCONFIG"; + device = newstralloc(device, amname_to_dirname(dle->device)); program->backup_name = VDUMP; program->restore_name = VRESTORE; dumpkeys = vstralloc(level_str, - options->no_record ? "" : "u", + !dle->record ? "" : "u", "b", "f", NULL); @@ -284,12 +348,13 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in " | ", "sed -e \'\n/^\\./ {\ns/^\\.//\ns/, [0-9]*$//\ns/^\\.//\ns/ @-> .*$//\nt\n}\nd\n\'", NULL); - write_tapeheader(); + info_tapeheader(dle); - start_index(options->createindex, dumpout, mesgf, indexf, indexcmd); + start_index(dle->create-index, dumpout, mesgf, indexf, indexcmd); - dumppid = pipespawn(cmd, STDIN_PIPE, + dumppid = pipespawn(cmd, STDIN_PIPE, 0, &dumpin, &dumpout, &mesgf, + cmdX, config, "vdump", dumpkeys, "60", @@ -305,12 +370,27 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in #define RESTORE "restore" #endif - dumpkeys = vstralloc(level_str, - options->no_record ? "" : "u", - "s", #ifdef HAVE_HONOR_NODUMP - "h", +# define PARAM_HONOR_NODUMP "h" +#else +# define PARAM_HONOR_NODUMP "" +#endif + +#ifdef __FreeBSD__ +# if defined(__FreeBSD_version) && (__FreeBSD_version >= 500043) +# define FREEBSD_EXTRA_KEYS "bL" +# else +# define FREEBSD_EXTRA_KEYS "b" +# endif +#else +# define FREEBSD_EXTRA_KEYS "" #endif + + dumpkeys = vstralloc(level_str, + !dle->record ? "" : "u", + FREEBSD_EXTRA_KEYS, + "s", + PARAM_HONOR_NODUMP, "f", NULL); @@ -321,14 +401,18 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in " | ", LEAF_AND_DIRS, NULL); - write_tapeheader(); + info_tapeheader(dle); - start_index(options->createindex, dumpout, mesgf, indexf, indexcmd); + start_index(dle->create_index, dumpout, mesgf, indexf, indexcmd); - dumppid = pipespawn(cmd, STDIN_PIPE, + dumppid = pipespawn(cmd, STDIN_PIPE, 0, &dumpin, &dumpout, &mesgf, + cmdX, config, "dump", dumpkeys, +#ifdef __FreeBSD__ + "64", +#endif "1048576", #ifdef HAVE_HONOR_NODUMP "0", @@ -341,7 +425,7 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in /* AIX backup program */ dumpkeys = vstralloc("-", level_str, - options->no_record ? "" : "u", + !dle->record ? "" : "u", "f", NULL); @@ -352,12 +436,13 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in " | ", LEAF_AND_DIRS, NULL); - write_tapeheader(); + info_tapeheader(dle); - start_index(options->createindex, dumpout, mesgf, indexf, indexcmd); + start_index(dle->create_index, dumpout, mesgf, indexf, indexcmd); - dumppid = pipespawn(cmd, STDIN_PIPE, + dumppid = pipespawn(cmd, STDIN_PIPE, 0, &dumpin, &dumpout, &mesgf, + cmdX, config, "backup", dumpkeys, "-", @@ -366,6 +451,7 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in #endif /* } */ amfree(dumpkeys); + amfree(fstype); amfree(device); amfree(cmd); amfree(indexcmd); @@ -374,15 +460,21 @@ static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, in aclose(dumpin); aclose(dumpout); + aclose(compout); aclose(dataf); aclose(mesgf); - if (options->createindex) + if (dle->create_index) aclose(indexf); } -static void end_backup(status) -int status; +static void +end_backup( + dle_t *dle, + int status) { + (void)dle; + (void)status; /* Quiet unused parameter warning */ + /* don't need to do anything for dump */ }