2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1998 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.65.2.5.4.2.2.9 2003/02/05 02:11:26 martinea Exp $
29 * send backup data using BSD dump
32 #include "sendbackup.h"
38 #include "sendbackup-krb4.h"
39 #else /* I'd tell you what this does */
40 #define NAUGHTY_BITS /* but then I'd have to kill you */
43 #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\'"
45 static regex_t re_table[] = {
46 /* the various encodings of dump size */
47 /* this should also match BSDI pre-3.0's buggy dump program, that
48 produced doubled DUMP: DUMP: messages */
49 AM_SIZE_RE("DUMP: [0-9][0-9]* tape blocks", 1024),
50 AM_SIZE_RE("dump: Actual: [0-9][0-9]* tape blocks", 1024),
51 AM_SIZE_RE("backup: There are [0-9][0-9]* tape blocks on [0-9][0-9]* tapes",
53 AM_SIZE_RE("backup: [0-9][0-9]* tape blocks on [0-9][0-9]* tape\\(s\\)",
55 AM_SIZE_RE("backup: [0-9][0-9]* 1k blocks on [0-9][0-9]* volume\\(s\\)",
57 AM_SIZE_RE("DUMP: [0-9][0-9]* blocks \\([0-9][0-9]*KB\\) on [0-9][0-9]* volume",
60 AM_SIZE_RE("DUMP: [0-9][0-9]* blocks \\([0-9][0-9]*\\.[0-9][0-9]*MB\\) on [0-9][0-9]* volume",
62 AM_SIZE_RE("DUMP: [0-9][0-9]* blocks", 512),
63 AM_SIZE_RE("DUMP: [0-9][0-9]* bytes were dumped", 1),
65 AM_SIZE_RE("vdump: Dumped [0-9][0-9]* of [0-9][0-9]* bytes", 1),
67 AM_SIZE_RE("dump: Actual: [0-9][0-9]* blocks output to pipe", 1024),
69 AM_SIZE_RE("dump: Dumped [0-9][0-9]* of [0-9][0-9]* bytes", 1),
71 AM_SIZE_RE("DUMP: [0-9][0-9]* KB actual output", 1024),
72 /* HPUX 10.20 and above vxdump */
73 AM_SIZE_RE("vxdump: [0-9][0-9]* tape blocks", 1024),
75 AM_SIZE_RE("vxdump: [0-9][0-9]* blocks", 1024),
77 AM_SIZE_RE(" VXDUMP: [0-9][0-9]* blocks", 512),
79 AM_SIZE_RE(" UFSDUMP: [0-9][0-9]* blocks", 512),
80 /* Irix 6.2 xfs dump */
81 AM_SIZE_RE("xfsdump: media file size [0-9][0-9]* bytes", 1),
83 AM_SIZE_RE("DUMP: [0-9][0-9]* KB", 1024),
85 /* strange dump lines */
86 AM_STRANGE_RE("should not happen"),
87 AM_STRANGE_RE("Cannot open"),
88 AM_STRANGE_RE("[Ee]rror"),
89 AM_STRANGE_RE("[Ff]ail"),
90 /* XXX add more ERROR entries here by scanning dump sources? */
92 /* any blank or non-strange DUMP: lines are marked as normal */
93 AM_NORMAL_RE("^ *DUMP:"),
94 AM_NORMAL_RE("^dump:"), /* OSF/1 */
95 AM_NORMAL_RE("^vdump:"), /* OSF/1 */
96 AM_NORMAL_RE("^ *vxdump:"), /* HPUX10 */
97 AM_NORMAL_RE("^ *vxfs *vxdump:"), /* Solaris */
98 AM_NORMAL_RE("^xfsdump:"), /* IRIX xfs */
99 AM_NORMAL_RE("^ *VXDUMP:"), /* Sinix */
100 AM_NORMAL_RE("^ *UFSDUMP:"), /* Sinix */
102 #ifdef VDUMP /* this is for OSF/1 3.2's vdump for advfs */
103 AM_NORMAL_RE("^The -s option is ignored"), /* OSF/1 */
104 AM_NORMAL_RE("^path"), /* OSF/1 */
105 AM_NORMAL_RE("^dev/fset"), /* OSF/1 */
106 AM_NORMAL_RE("^type"), /* OSF/1 */
107 AM_NORMAL_RE("^advfs id"), /* OSF/1 */
108 AM_NORMAL_RE("^[A-Z][a-z][a-z] [A-Z][a-z][a-z] .[0-9] [0-9]"), /* OSF/1 */
111 AM_NORMAL_RE("^backup:"), /* AIX */
112 AM_NORMAL_RE("^ Use the umount command to unmount the filesystem"),
114 AM_NORMAL_RE("^[ \t]*$"),
116 /* catch-all; DMP_STRANGE is returned for all other lines */
120 static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, indexf)
122 char *disk, *amdevice;
123 int level, dataf, mesgf, indexf;
127 char *dumpkeys = NULL;
131 char *indexcmd = NULL;
132 char level_str[NUM_STR_SIZE];
134 ap_snprintf(level_str, sizeof(level_str), "%d", level);
136 fprintf(stderr, "%s: start [%s:%s level %d]\n",
137 get_pname(), host, disk, level);
141 if(options->compress == COMPR_FAST || options->compress == COMPR_BEST) {
142 char *compopt = skip_argument;
144 #if defined(COMPRESS_BEST_OPT) && defined(COMPRESS_FAST_OPT)
145 if(options->compress == COMPR_BEST) {
146 compopt = COMPRESS_BEST_OPT;
148 compopt = COMPRESS_FAST_OPT;
151 comppid = pipespawn(COMPRESS_PATH, STDIN_PIPE,
152 &dumpout, &dataf, &mesgf,
153 COMPRESS_PATH, compopt, NULL);
154 dbprintf(("%s: pid %ld: %s",
155 debug_prefix_time("-dump"), (long)comppid, COMPRESS_PATH));
156 if(compopt != skip_argument) {
157 dbprintf((" %s", compopt));
166 device = amname_to_devname(amdevice);
167 fstype = amname_to_fstype(amdevice);
169 dbprintf(("%s: dumping device '%s' with '%s'\n",
170 debug_prefix_time(NULL), device, fstype));
172 #if defined(USE_RUNDUMP) || !defined(DUMP)
173 cmd = vstralloc(libexecdir, "/", "rundump", versionsuffix(), NULL);
175 cmd = stralloc(DUMP);
178 #ifndef AIX_BACKUP /* { */
180 #ifdef XFSDUMP /* { */
182 if (strcmp(amname_to_fstype(amdevice), "xfs") == 0)
187 char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump",
188 versionsuffix(), NULL);
189 program->backup_name = XFSDUMP;
190 program->restore_name = XFSRESTORE;
192 indexcmd = vstralloc(XFSRESTORE,
198 " -e", " \'s/^/\\//\'",
202 start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
204 dumpkeys = stralloc(level_str);
205 dumppid = pipespawn(progname, STDIN_PIPE,
206 &dumpin, &dumpout, &mesgf,
208 options->no_record ? "-J" : skip_argument,
217 #ifdef VXDUMP /* { */
219 if (strcmp(amname_to_fstype(amdevice), "vxfs") == 0)
225 char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump",
226 versionsuffix(), NULL);
228 char *progname = cmd = newvstralloc(cmd, VXDUMP, NULL);
230 program->backup_name = VXDUMP;
231 program->restore_name = VXRESTORE;
233 dumpkeys = vstralloc(level_str,
234 options->no_record ? "" : "u",
239 indexcmd = vstralloc(VXRESTORE,
247 start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
249 dumppid = pipespawn(progname, STDIN_PIPE,
250 &dumpin, &dumpout, &mesgf,
263 if (strcmp(amname_to_fstype(amdevice), "advfs") == 0)
268 char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump",
269 versionsuffix(), NULL);
270 device = newstralloc(device, amname_to_dirname(amdevice));
271 program->backup_name = VDUMP;
272 program->restore_name = VRESTORE;
274 dumpkeys = vstralloc(level_str,
275 options->no_record ? "" : "u",
280 indexcmd = vstralloc(VRESTORE,
284 "sed -e \'\n/^\\./ {\ns/^\\.//\ns/, [0-9]*$//\ns/^\\.//\ns/ @-> .*$//\nt\n}\nd\n\'",
288 start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
290 dumppid = pipespawn(cmd, STDIN_PIPE,
291 &dumpin, &dumpout, &mesgf,
304 #define RESTORE "restore"
307 dumpkeys = vstralloc(level_str,
308 options->no_record ? "" : "u",
310 #ifdef HAVE_HONOR_NODUMP
316 indexcmd = vstralloc(RESTORE,
319 /* not to /dev/null because of DU's dump */
325 start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
327 dumppid = pipespawn(cmd, STDIN_PIPE,
328 &dumpin, &dumpout, &mesgf,
332 #ifdef HAVE_HONOR_NODUMP
340 /* AIX backup program */
341 dumpkeys = vstralloc("-",
343 options->no_record ? "" : "u",
347 indexcmd = vstralloc(RESTORE,
356 start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
358 dumppid = pipespawn(cmd, STDIN_PIPE,
359 &dumpin, &dumpout, &mesgf,
372 /* close the write ends of the pipes */
378 if (options->createindex)
382 static void end_backup(status)
385 /* don't need to do anything for dump */
388 backup_program_t dump_program = {
398 re_table, start_backup, end_backup