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.2.1 2005/09/20 18:13:08 jrjackson 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", 1024),
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("^Dumping .* to stdout"), /* Solaris vxdump */
99 AM_NORMAL_RE("^xfsdump:"), /* IRIX xfs */
100 AM_NORMAL_RE("^ *VXDUMP:"), /* Sinix */
101 AM_NORMAL_RE("^ *UFSDUMP:"), /* Sinix */
103 #ifdef VDUMP /* this is for OSF/1 3.2's vdump for advfs */
104 AM_NORMAL_RE("^The -s option is ignored"), /* OSF/1 */
105 AM_NORMAL_RE("^path"), /* OSF/1 */
106 AM_NORMAL_RE("^dev/fset"), /* OSF/1 */
107 AM_NORMAL_RE("^type"), /* OSF/1 */
108 AM_NORMAL_RE("^advfs id"), /* OSF/1 */
109 AM_NORMAL_RE("^[A-Z][a-z][a-z] [A-Z][a-z][a-z] .[0-9] [0-9]"), /* OSF/1 */
112 AM_NORMAL_RE("^backup:"), /* AIX */
113 AM_NORMAL_RE("^ Use the umount command to unmount the filesystem"),
115 AM_NORMAL_RE("^[ \t]*$"),
117 /* catch-all; DMP_STRANGE is returned for all other lines */
121 static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, indexf)
123 char *disk, *amdevice;
124 int level, dataf, mesgf, indexf;
128 char *dumpkeys = NULL;
132 char *indexcmd = NULL;
133 char level_str[NUM_STR_SIZE];
135 ap_snprintf(level_str, sizeof(level_str), "%d", level);
137 fprintf(stderr, "%s: start [%s:%s level %d]\n",
138 get_pname(), host, disk, level);
142 if(options->compress == COMPR_FAST || options->compress == COMPR_BEST) {
143 char *compopt = skip_argument;
145 #if defined(COMPRESS_BEST_OPT) && defined(COMPRESS_FAST_OPT)
146 if(options->compress == COMPR_BEST) {
147 compopt = COMPRESS_BEST_OPT;
149 compopt = COMPRESS_FAST_OPT;
152 comppid = pipespawn(COMPRESS_PATH, STDIN_PIPE,
153 &dumpout, &dataf, &mesgf,
154 COMPRESS_PATH, compopt, NULL);
155 dbprintf(("%s: pid %ld: %s",
156 debug_prefix_time("-dump"), (long)comppid, COMPRESS_PATH));
157 if(compopt != skip_argument) {
158 dbprintf((" %s", compopt));
167 device = amname_to_devname(amdevice);
168 fstype = amname_to_fstype(amdevice);
170 dbprintf(("%s: dumping device '%s' with '%s'\n",
171 debug_prefix_time(NULL), device, fstype));
173 #if defined(USE_RUNDUMP) || !defined(DUMP)
174 cmd = vstralloc(libexecdir, "/", "rundump", versionsuffix(), NULL);
176 cmd = stralloc(DUMP);
179 #ifndef AIX_BACKUP /* { */
181 #ifdef XFSDUMP /* { */
183 if (strcmp(amname_to_fstype(amdevice), "xfs") == 0)
188 char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump",
189 versionsuffix(), NULL);
190 program->backup_name = XFSDUMP;
191 program->restore_name = XFSRESTORE;
193 indexcmd = vstralloc(XFSRESTORE,
199 " -e", " \'s/^/\\//\'",
203 start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
205 dumpkeys = stralloc(level_str);
206 dumppid = pipespawn(progname, STDIN_PIPE,
207 &dumpin, &dumpout, &mesgf,
209 options->no_record ? "-J" : skip_argument,
218 #ifdef VXDUMP /* { */
220 if (strcmp(amname_to_fstype(amdevice), "vxfs") == 0)
226 char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump",
227 versionsuffix(), NULL);
229 char *progname = cmd = newvstralloc(cmd, VXDUMP, NULL);
231 program->backup_name = VXDUMP;
232 program->restore_name = VXRESTORE;
234 dumpkeys = vstralloc(level_str,
235 options->no_record ? "" : "u",
240 indexcmd = vstralloc(VXRESTORE,
248 start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
250 dumppid = pipespawn(progname, STDIN_PIPE,
251 &dumpin, &dumpout, &mesgf,
264 if (strcmp(amname_to_fstype(amdevice), "advfs") == 0)
269 char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump",
270 versionsuffix(), NULL);
271 device = newstralloc(device, amname_to_dirname(amdevice));
272 program->backup_name = VDUMP;
273 program->restore_name = VRESTORE;
275 dumpkeys = vstralloc(level_str,
276 options->no_record ? "" : "u",
281 indexcmd = vstralloc(VRESTORE,
285 "sed -e \'\n/^\\./ {\ns/^\\.//\ns/, [0-9]*$//\ns/^\\.//\ns/ @-> .*$//\nt\n}\nd\n\'",
289 start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
291 dumppid = pipespawn(cmd, STDIN_PIPE,
292 &dumpin, &dumpout, &mesgf,
305 #define RESTORE "restore"
308 dumpkeys = vstralloc(level_str,
309 options->no_record ? "" : "u",
311 #ifdef HAVE_HONOR_NODUMP
317 indexcmd = vstralloc(RESTORE,
320 /* not to /dev/null because of DU's dump */
326 start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
328 dumppid = pipespawn(cmd, STDIN_PIPE,
329 &dumpin, &dumpout, &mesgf,
333 #ifdef HAVE_HONOR_NODUMP
341 /* AIX backup program */
342 dumpkeys = vstralloc("-",
344 options->no_record ? "" : "u",
348 indexcmd = vstralloc(RESTORE,
357 start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
359 dumppid = pipespawn(cmd, STDIN_PIPE,
360 &dumpin, &dumpout, &mesgf,
373 /* close the write ends of the pipes */
379 if (options->createindex)
383 static void end_backup(status)
386 /* don't need to do anything for dump */
389 backup_program_t dump_program = {
399 re_table, start_backup, end_backup