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.88 2006/03/09 20:06:11 johnfranks Exp $
29 * send backup data using BSD dump
32 #include "sendbackup.h"
37 #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\'"
39 static regex_t re_table[] = {
40 /* the various encodings of dump size */
41 /* this should also match BSDI pre-3.0's buggy dump program, that
42 produced doubled DUMP: DUMP: messages */
43 AM_SIZE_RE("DUMP: [0-9][0-9]* tape blocks", 1024),
44 AM_SIZE_RE("dump: Actual: [0-9][0-9]* tape blocks", 1024),
45 AM_SIZE_RE("backup: There are [0-9][0-9]* tape blocks on [0-9][0-9]* tapes",
47 AM_SIZE_RE("backup: [0-9][0-9]* tape blocks on [0-9][0-9]* tape\\(s\\)",
49 AM_SIZE_RE("backup: [0-9][0-9]* 1k blocks on [0-9][0-9]* volume\\(s\\)",
51 AM_SIZE_RE("DUMP: [0-9][0-9]* blocks \\([0-9][0-9]*KB\\) on [0-9][0-9]* volume",
53 AM_SIZE_RE("DUMP: [0-9][0-9]* blocks \\([0-9][0-9]*\\.[0-9][0-9]*MB\\) on [0-9][0-9]* volume",
55 AM_SIZE_RE("DUMP: [0-9][0-9]* blocks", 1024),
56 AM_SIZE_RE("DUMP: [0-9][0-9]* bytes were dumped", 1),
58 AM_SIZE_RE("vdump: Dumped [0-9][0-9]* of [0-9][0-9]* bytes", 1),
60 AM_SIZE_RE("dump: Actual: [0-9][0-9]* blocks output to pipe", 1024),
62 AM_SIZE_RE("dump: Dumped [0-9][0-9]* of [0-9][0-9]* bytes", 1),
64 AM_SIZE_RE("DUMP: [0-9][0-9]* KB actual output", 1024),
65 /* HPUX 10.20 and above vxdump */
66 AM_SIZE_RE("vxdump: [0-9][0-9]* tape blocks", 1024),
68 AM_SIZE_RE("vxdump: [0-9][0-9]* blocks", 1024),
70 AM_SIZE_RE(" VXDUMP: [0-9][0-9]* blocks", 512),
72 AM_SIZE_RE(" UFSDUMP: [0-9][0-9]* blocks", 512),
73 /* Irix 6.2 xfs dump */
74 AM_SIZE_RE("xfsdump: media file size [0-9][0-9]* bytes", 1),
76 AM_SIZE_RE("DUMP: [0-9][0-9]* KB", 1024),
78 /* strange dump lines */
79 AM_STRANGE_RE("should not happen"),
80 AM_STRANGE_RE("Cannot open"),
81 AM_STRANGE_RE("[Ee]rror"),
82 AM_STRANGE_RE("[Ff]ail"),
83 /* XXX add more ERROR entries here by scanning dump sources? */
85 /* any blank or non-strange DUMP: lines are marked as normal */
86 AM_NORMAL_RE("^ *DUMP:"),
87 AM_NORMAL_RE("^dump:"), /* OSF/1 */
88 AM_NORMAL_RE("^vdump:"), /* OSF/1 */
89 AM_NORMAL_RE("^ *vxdump:"), /* HPUX10 */
90 AM_NORMAL_RE("^ *vxfs *vxdump:"), /* Solaris */
91 AM_NORMAL_RE("^Dumping .* to stdout"), /* Sol vxdump */
92 AM_NORMAL_RE("^xfsdump:"), /* IRIX xfs */
93 AM_NORMAL_RE("^ *VXDUMP:"), /* Sinix */
94 AM_NORMAL_RE("^ *UFSDUMP:"), /* Sinix */
96 #ifdef VDUMP /* this is for OSF/1 3.2's vdump for advfs */
97 AM_NORMAL_RE("^The -s option is ignored"), /* OSF/1 */
98 AM_NORMAL_RE("^path"), /* OSF/1 */
99 AM_NORMAL_RE("^dev/fset"), /* OSF/1 */
100 AM_NORMAL_RE("^type"), /* OSF/1 */
101 AM_NORMAL_RE("^advfs id"), /* OSF/1 */
102 AM_NORMAL_RE("^[A-Z][a-z][a-z] [A-Z][a-z][a-z] .[0-9] [0-9]"), /* OSF/1 */
105 AM_NORMAL_RE("^backup:"), /* AIX */
106 AM_NORMAL_RE("^ Use the umount command to unmount the filesystem"),
108 AM_NORMAL_RE("^[ \t]*$"),
110 /* catch-all; DMP_STRANGE is returned for all other lines */
115 * doing similar to $ dump | compression | encryption
118 static void start_backup(host, disk, amdevice, level, dumpdate, dataf, mesgf, indexf)
120 char *disk, *amdevice;
121 int level, dataf, mesgf, indexf;
124 int dumpin, dumpout, compout;
125 char *dumpkeys = NULL;
129 char *indexcmd = NULL;
130 char level_str[NUM_STR_SIZE];
131 char *compopt = NULL;
132 char *encryptopt = skip_argument;
135 snprintf(level_str, sizeof(level_str), "%d", level);
137 fprintf(stderr, "%s: start [%s:%s level %d]\n",
138 get_pname(), host, disk, level);
140 /* apply client-side encryption here */
141 if ( options->encrypt == ENCRYPT_CUST ) {
142 encpid = pipespawn(options->clnt_encrypt, STDIN_PIPE,
143 &compout, &dataf, &mesgf,
144 options->clnt_encrypt, encryptopt, NULL);
145 dbprintf(("%s: pid %ld: %s\n",
146 debug_prefix_time("-gnutar"), (long)encpid, options->clnt_encrypt));
151 /* now do the client-side compression */
154 if(options->compress == COMPR_FAST || options->compress == COMPR_BEST) {
155 compopt = skip_argument;
157 #if defined(COMPRESS_BEST_OPT) && defined(COMPRESS_FAST_OPT)
158 if(options->compress == COMPR_BEST) {
159 compopt = COMPRESS_BEST_OPT;
161 compopt = COMPRESS_FAST_OPT;
164 comppid = pipespawn(COMPRESS_PATH, STDIN_PIPE,
165 &dumpout, &compout, &mesgf,
166 COMPRESS_PATH, compopt, NULL);
167 dbprintf(("%s: pid %ld: %s",
168 debug_prefix_time("-dump"), (long)comppid, COMPRESS_PATH));
169 if(compopt != skip_argument) {
170 dbprintf((" %s", compopt));
173 } else if (options->compress == COMPR_CUST) {
174 compopt = skip_argument;
175 comppid = pipespawn(options->clntcompprog, STDIN_PIPE,
176 &dumpout, &compout, &mesgf,
177 options->clntcompprog, compopt, NULL);
178 dbprintf(("%s: pid %ld: %s",
179 debug_prefix_time("-gnutar-cust"), (long)comppid, options->clntcompprog));
180 if(compopt != skip_argument) {
181 dbprintf((" %s", compopt));
190 device = amname_to_devname(amdevice);
191 fstype = amname_to_fstype(amdevice);
193 dbprintf(("%s: dumping device '%s' with '%s'\n",
194 debug_prefix_time(NULL), device, fstype));
196 #if defined(USE_RUNDUMP) || !defined(DUMP)
197 cmd = vstralloc(libexecdir, "/", "rundump", versionsuffix(), NULL);
199 cmd = stralloc(DUMP);
202 #ifndef AIX_BACKUP /* { */
204 #ifdef XFSDUMP /* { */
206 if (strcmp(amname_to_fstype(amdevice), "xfs") == 0)
211 char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump",
212 versionsuffix(), NULL);
213 program->backup_name = XFSDUMP;
214 program->restore_name = XFSRESTORE;
216 indexcmd = vstralloc(XFSRESTORE,
222 " -e", " \'s/^/\\//\'",
226 start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
228 dumpkeys = stralloc(level_str);
229 dumppid = pipespawn(progname, STDIN_PIPE,
230 &dumpin, &dumpout, &mesgf,
232 options->no_record ? "-J" : skip_argument,
241 #ifdef VXDUMP /* { */
243 if (strcmp(amname_to_fstype(amdevice), "vxfs") == 0)
249 char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump",
250 versionsuffix(), NULL);
252 char *progname = cmd = newvstralloc(cmd, VXDUMP, NULL);
254 program->backup_name = VXDUMP;
255 program->restore_name = VXRESTORE;
257 dumpkeys = vstralloc(level_str,
258 options->no_record ? "" : "u",
263 indexcmd = vstralloc(VXRESTORE,
271 start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
273 dumppid = pipespawn(progname, STDIN_PIPE,
274 &dumpin, &dumpout, &mesgf,
287 if (strcmp(amname_to_fstype(amdevice), "advfs") == 0)
292 char *progname = cmd = newvstralloc(cmd, libexecdir, "/", "rundump",
293 versionsuffix(), NULL);
294 device = newstralloc(device, amname_to_dirname(amdevice));
295 program->backup_name = VDUMP;
296 program->restore_name = VRESTORE;
298 dumpkeys = vstralloc(level_str,
299 options->no_record ? "" : "u",
304 indexcmd = vstralloc(VRESTORE,
308 "sed -e \'\n/^\\./ {\ns/^\\.//\ns/, [0-9]*$//\ns/^\\.//\ns/ @-> .*$//\nt\n}\nd\n\'",
312 start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
314 dumppid = pipespawn(cmd, STDIN_PIPE,
315 &dumpin, &dumpout, &mesgf,
328 #define RESTORE "restore"
331 dumpkeys = vstralloc(level_str,
332 options->no_record ? "" : "u",
334 #ifdef HAVE_HONOR_NODUMP
340 indexcmd = vstralloc(RESTORE,
343 /* not to /dev/null because of DU's dump */
349 start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
351 dumppid = pipespawn(cmd, STDIN_PIPE,
352 &dumpin, &dumpout, &mesgf,
356 #ifdef HAVE_HONOR_NODUMP
364 /* AIX backup program */
365 dumpkeys = vstralloc("-",
367 options->no_record ? "" : "u",
371 indexcmd = vstralloc(RESTORE,
380 start_index(options->createindex, dumpout, mesgf, indexf, indexcmd);
382 dumppid = pipespawn(cmd, STDIN_PIPE,
383 &dumpin, &dumpout, &mesgf,
397 /* close the write ends of the pipes */
404 if (options->createindex)
408 static void end_backup(status)
411 /* don't need to do anything for dump */
414 backup_program_t dump_program = {
424 re_table, start_backup, end_backup