2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1999 University of Maryland at College Park
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of U.M. not be used in advertising or
11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. U.M. makes no representations about the
13 * suitability of this software for any purpose. It is provided "as is"
14 * without express or implied warranty.
16 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Authors: the Amanda Development Team. Its members are listed in a
24 * file named AUTHORS, in the root directory of this distribution.
27 * $Id: sendbackup-dump.c,v 1.90.2.2 2006/11/24 18:10:38 martinea Exp $
29 * send backup data using BSD dump
33 #include "sendbackup.h"
38 #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\'"
40 static amregex_t re_table[] = {
41 /* the various encodings of dump size */
42 /* this should also match BSDI pre-3.0's buggy dump program, that
43 produced doubled DUMP: DUMP: messages */
44 AM_SIZE_RE("DUMP: [0-9][0-9]* tape blocks", 1024),
45 AM_SIZE_RE("dump: Actual: [0-9][0-9]* tape blocks", 1024),
46 AM_SIZE_RE("backup: There are [0-9][0-9]* tape blocks on [0-9][0-9]* tapes",
48 AM_SIZE_RE("backup: [0-9][0-9]* tape blocks on [0-9][0-9]* tape\\(s\\)",
50 AM_SIZE_RE("backup: [0-9][0-9]* 1k blocks on [0-9][0-9]* volume\\(s\\)",
52 AM_SIZE_RE("DUMP: [0-9][0-9]* blocks \\([0-9][0-9]*KB\\) on [0-9][0-9]* volume",
54 AM_SIZE_RE("DUMP: [0-9][0-9]* blocks \\([0-9][0-9]*\\.[0-9][0-9]*MB\\) on [0-9][0-9]* volume",
56 AM_SIZE_RE("DUMP: [0-9][0-9]* blocks", 512),
57 AM_SIZE_RE("DUMP: [0-9][0-9]* bytes were dumped", 1),
59 AM_SIZE_RE("vdump: Dumped [0-9][0-9]* of [0-9][0-9]* bytes", 1),
61 AM_SIZE_RE("dump: Actual: [0-9][0-9]* blocks output to pipe", 1024),
63 AM_SIZE_RE("dump: Dumped [0-9][0-9]* of [0-9][0-9]* bytes", 1),
65 AM_SIZE_RE("DUMP: [0-9][0-9]* KB actual output", 1024),
66 /* HPUX 10.20 and above vxdump */
67 AM_SIZE_RE("vxdump: [0-9][0-9]* tape blocks", 1024),
69 AM_SIZE_RE("vxdump: [0-9][0-9]* blocks", 1024),
71 AM_SIZE_RE(" VXDUMP: [0-9][0-9]* blocks", 512),
73 AM_SIZE_RE(" UFSDUMP: [0-9][0-9]* blocks", 512),
74 /* Irix 6.2 xfs dump */
75 AM_SIZE_RE("xfsdump: media file size [0-9][0-9]* bytes", 1),
77 AM_SIZE_RE("DUMP: [0-9][0-9]* KB", 1024),
79 /* strange dump lines */
80 AM_STRANGE_RE("should not happen"),
81 AM_STRANGE_RE("Cannot open"),
82 AM_STRANGE_RE("[Ee]rror"),
83 AM_STRANGE_RE("[Ff]ail"),
84 /* XXX add more ERROR entries here by scanning dump sources? */
86 /* any blank or non-strange DUMP: lines are marked as normal */
87 AM_NORMAL_RE("^ *DUMP:"),
88 AM_NORMAL_RE("^dump:"), /* OSF/1 */
89 AM_NORMAL_RE("^vdump:"), /* OSF/1 */
90 AM_NORMAL_RE("^ *vxdump:"), /* HPUX10 */
91 AM_NORMAL_RE("^ *vxfs *vxdump:"), /* Solaris */
92 AM_NORMAL_RE("^Dumping .* to stdout"), /* Sol vxdump */
93 AM_NORMAL_RE("^xfsdump:"), /* IRIX xfs */
94 AM_NORMAL_RE("^ *VXDUMP:"), /* Sinix */
95 AM_NORMAL_RE("^ *UFSDUMP:"), /* Sinix */
97 #ifdef VDUMP /* this is for OSF/1 3.2's vdump for advfs */
98 AM_NORMAL_RE("^The -s option is ignored"), /* OSF/1 */
99 AM_NORMAL_RE("^path"), /* OSF/1 */
100 AM_NORMAL_RE("^dev/fset"), /* OSF/1 */
101 AM_NORMAL_RE("^type"), /* OSF/1 */
102 AM_NORMAL_RE("^advfs id"), /* OSF/1 */
103 AM_NORMAL_RE("^[A-Z][a-z][a-z] [A-Z][a-z][a-z] .[0-9] [0-9]"), /* OSF/1 */
106 AM_NORMAL_RE("^backup:"), /* AIX */
107 AM_NORMAL_RE("^ Use the umount command to unmount the filesystem"),
109 AM_NORMAL_RE("^[ \t]*$"),
111 /* catch-all; DMP_STRANGE is returned for all other lines */
115 static void start_backup(char *host, char *disk, char *amdevice, int level,
116 char *dumpdate, int dataf, int mesgf, int indexf);
117 static void end_backup(int status);
120 * doing similar to $ dump | compression | encryption
134 int dumpin, dumpout, compout;
135 char *dumpkeys = NULL;
140 char *indexcmd = NULL;
141 char level_str[NUM_STR_SIZE];
142 char *compopt = NULL;
143 char *encryptopt = skip_argument;
147 (void)dumpdate; /* Quiet unused parameter warning */
149 snprintf(level_str, SIZEOF(level_str), "%d", level);
151 qdisk = quote_string(disk);
152 dbprintf(("%s: start: %s:%s lev %d\n",
153 get_pname(), host, qdisk, level));
155 fprintf(stderr, "%s: start [%s:%s level %d]\n",
156 get_pname(), host, qdisk, level);
159 /* apply client-side encryption here */
160 if ( options->encrypt == ENCRYPT_CUST ) {
161 encpid = pipespawn(options->clnt_encrypt, STDIN_PIPE,
162 &compout, &dataf, &mesgf,
163 options->clnt_encrypt, encryptopt, NULL);
164 dbprintf(("%s: pid %ld: %s\n",
165 debug_prefix_time("-gnutar"), (long)encpid, options->clnt_encrypt));
170 /* now do the client-side compression */
173 if(options->compress == COMPR_FAST || options->compress == COMPR_BEST) {
174 compopt = skip_argument;
176 #if defined(COMPRESS_BEST_OPT) && defined(COMPRESS_FAST_OPT)
177 if(options->compress == COMPR_BEST) {
178 compopt = COMPRESS_BEST_OPT;
180 compopt = COMPRESS_FAST_OPT;
183 comppid = pipespawn(COMPRESS_PATH, STDIN_PIPE,
184 &dumpout, &compout, &mesgf,
185 COMPRESS_PATH, compopt, NULL);
186 dbprintf(("%s: pid %ld: %s",
187 debug_prefix_time("-dump"), (long)comppid, COMPRESS_PATH));
188 if(compopt != skip_argument) {
189 dbprintf((" %s", compopt));
192 } else if (options->compress == COMPR_CUST) {
193 compopt = skip_argument;
194 comppid = pipespawn(options->clntcompprog, STDIN_PIPE,
195 &dumpout, &compout, &mesgf,
196 options->clntcompprog, compopt, NULL);
197 dbprintf(("%s: pid %ld: %s",
198 debug_prefix_time("-gnutar-cust"), (long)comppid, options->clntcompprog));
199 if(compopt != skip_argument) {
200 dbprintf((" %s", compopt));
209 device = amname_to_devname(amdevice);
210 fstype = amname_to_fstype(amdevice);
212 dbprintf(("%s: dumping device '%s' with '%s'\n",
213 debug_prefix_time(NULL), device, fstype));
215 #if defined(USE_RUNDUMP) || !defined(DUMP)
216 cmd = vstralloc(libexecdir, "/", "rundump", versionsuffix(), NULL);
218 if (g_options->config)
219 config = g_options->config;
223 cmd = stralloc(DUMP);
224 cmdX = skip_argument;
225 config = skip_argument;
228 #ifndef AIX_BACKUP /* { */
230 #ifdef XFSDUMP /* { */
232 if (strcmp(amname_to_fstype(amdevice), "xfs") == 0)
237 char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump",
238 versionsuffix(), NULL);
240 if (g_options->config)
241 config = g_options->config;
245 program->backup_name = XFSDUMP;
246 program->restore_name = XFSRESTORE;
248 indexcmd = vstralloc(XFSRESTORE,
254 " -e", " \'s/^/\\//\'",
258 start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
260 dumpkeys = stralloc(level_str);
261 dumppid = pipespawn(progname, STDIN_PIPE,
262 &dumpin, &dumpout, &mesgf,
265 options->no_record ? "-J" : skip_argument,
274 #ifdef VXDUMP /* { */
276 if (strcmp(amname_to_fstype(amdevice), "vxfs") == 0)
282 char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump",
283 versionsuffix(), NULL);
285 if (g_options->config)
286 config = g_options->config;
290 char *progname = cmd = newvstralloc(cmd, VXDUMP, NULL);
291 cmdX = skip_argument;
292 config = skip_argument;
294 program->backup_name = VXDUMP;
295 program->restore_name = VXRESTORE;
297 dumpkeys = vstralloc(level_str,
298 options->no_record ? "" : "u",
303 indexcmd = vstralloc(VXRESTORE,
311 start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
313 dumppid = pipespawn(progname, STDIN_PIPE,
314 &dumpin, &dumpout, &mesgf,
328 if (strcmp(amname_to_fstype(amdevice), "advfs") == 0)
333 char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump",
334 versionsuffix(), NULL);
336 if (g_options->config)
337 config = g_options->config;
340 device = newstralloc(device, amname_to_dirname(amdevice));
341 program->backup_name = VDUMP;
342 program->restore_name = VRESTORE;
344 dumpkeys = vstralloc(level_str,
345 options->no_record ? "" : "u",
350 indexcmd = vstralloc(VRESTORE,
354 "sed -e \'\n/^\\./ {\ns/^\\.//\ns/, [0-9]*$//\ns/^\\.//\ns/ @-> .*$//\nt\n}\nd\n\'",
358 start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
360 dumppid = pipespawn(cmd, STDIN_PIPE,
361 &dumpin, &dumpout, &mesgf,
375 #define RESTORE "restore"
378 #ifdef HAVE_HONOR_NODUMP
379 # define PARAM_HONOR_NODUMP "h"
381 # define PARAM_HONOR_NODUMP ""
383 dumpkeys = vstralloc(level_str,
384 options->no_record ? "" : "u",
390 indexcmd = vstralloc(RESTORE,
393 /* not to /dev/null because of DU's dump */
399 start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
401 dumppid = pipespawn(cmd, STDIN_PIPE,
402 &dumpin, &dumpout, &mesgf,
407 #ifdef HAVE_HONOR_NODUMP
415 /* AIX backup program */
416 dumpkeys = vstralloc("-",
418 options->no_record ? "" : "u",
422 indexcmd = vstralloc(RESTORE,
431 start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
433 dumppid = pipespawn(cmd, STDIN_PIPE,
434 &dumpin, &dumpout, &mesgf,
449 /* close the write ends of the pipes */
456 if (options->createindex)
464 (void)status; /* Quiet unused parameter warning */
466 /* don't need to do anything for dump */
469 backup_program_t dump_program = {
479 re_table, start_backup, end_backup