Add -U flag to dump(8) and dump_lfs(8) to specify dumpdates entry

This address situations where dump(8) cannot figure out the device being
dumped. It also allows tracking of subvolume dumps by using virtual
device as dumpdates entry.
This commit is contained in:
manu 2019-03-25 02:13:01 +00:00
parent 6b80e73dd2
commit eeb96f8c80
5 changed files with 47 additions and 16 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: dump.8,v 1.69 2018/07/15 06:14:13 dholland Exp $
.\" $NetBSD: dump.8,v 1.70 2019/03/25 02:13:01 manu Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" Regents of the University of California.
@ -51,6 +51,7 @@
.Op Fl r Ar cachesize
.Op Fl s Ar feet
.Op Fl T Ar date
.Op Fl U Ar dumpdev
.Op Fl x Ar snap-backup
.Ar files-to-dump
.Nm
@ -299,10 +300,22 @@ The file
.Pa /etc/dumpdates
may be edited to change any of the fields,
if necessary.
If a list of files or subdirectories is being dumped
If the
.Fl T
option is used or if a list of files or subdirectories is being dumped
(as opposed to an entire file system), then
.Fl u
is ignored.
.It Fl U Ar dumpdev
Same as
.Fl u
but specifies the device in
.Pa /etc/dumpdates
as
.Ar dumpdev .
This option can be used with subdir dumps and with the
.Fl T
option.
.It Fl W
.Nm
tells the operator what file systems need to be dumped.

View File

@ -1,4 +1,4 @@
/* $NetBSD: dump.h,v 1.56 2019/03/01 16:42:11 christos Exp $ */
/* $NetBSD: dump.h,v 1.57 2019/03/25 02:13:01 manu Exp $ */
/*-
* Copyright (c) 1980, 1993
@ -115,6 +115,7 @@ const char *temp; /* name of the file for doing rewrite of dumpdates */
char lastlevel; /* dump level of previous dump */
char level; /* dump level of this dump */
int uflag; /* update flag */
const char *dumpdev; /* device name in dumpdates */
int eflag; /* eject flag */
int lflag; /* autoload flag */
int diskfd; /* disk file descriptor */

View File

@ -1,4 +1,4 @@
/* $NetBSD: itime.c,v 1.21 2019/03/01 16:42:11 christos Exp $ */
/* $NetBSD: itime.c,v 1.22 2019/03/25 02:13:01 manu Exp $ */
/*-
* Copyright (c) 1980, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)itime.c 8.1 (Berkeley) 6/5/93";
#else
__RCSID("$NetBSD: itime.c,v 1.21 2019/03/01 16:42:11 christos Exp $");
__RCSID("$NetBSD: itime.c,v 1.22 2019/03/25 02:13:01 manu Exp $");
#endif
#endif /* not lint */
@ -129,9 +129,9 @@ getdumptime(void)
{
struct dumpdates *ddp;
int i;
char *fname;
const char *fname;
fname = disk;
fname = dumpdev ? dumpdev : disk;
#ifdef FDEBUG
msg("Looking for name %s in dumpdates = %s for level = %c\n",
fname, dumpdates, level);
@ -170,15 +170,15 @@ putdumptime(void)
struct dumpdates *dtwalk, *dtfound;
int i;
int fd;
char *fname;
const char *fname;
if(uflag == 0)
if (uflag == 0 && dumpdev == NULL)
return;
if ((df = fopen(dumpdates, "r+")) == NULL)
quite(errno, "cannot rewrite %s", dumpdates);
fd = fileno(df);
(void) flock(fd, LOCK_EX);
fname = disk;
fname = dumpdev ? dumpdev : disk;
free((char *)ddatev);
ddatev = 0;
nddates = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.74 2019/03/01 16:42:11 christos Exp $ */
/* $NetBSD: main.c,v 1.75 2019/03/25 02:13:01 manu Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993, 1994
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1991, 1993, 1994\
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/1/95";
#else
__RCSID("$NetBSD: main.c,v 1.74 2019/03/01 16:42:11 christos Exp $");
__RCSID("$NetBSD: main.c,v 1.75 2019/03/25 02:13:01 manu Exp $");
#endif
#endif /* not lint */
@ -133,7 +133,7 @@ main(int argc, char *argv[])
obsolete(&argc, &argv);
while ((ch = getopt(argc, argv,
"0123456789aB:b:cd:eFf:h:ik:l:L:nr:s:StT:uWwx:X")) != -1)
"0123456789aB:b:cd:eFf:h:ik:l:L:nr:s:StT:uU:Wwx:X")) != -1)
switch (ch) {
/* dump level */
case '0': case '1': case '2': case '3': case '4':
@ -245,6 +245,10 @@ main(int argc, char *argv[])
uflag = 1;
break;
case 'U': /* dump device in /etc/dumpdates */
dumpdev = optarg;
break;
case 'W': /* what to do */
case 'w':
lastdump(ch);
@ -674,7 +678,7 @@ usage(void)
"usage: %s [-0123456789aceFinStuX] [-B records] [-b blocksize]\n"
" [-d density] [-f file] [-h level] [-k read-blocksize]\n"
" [-L label] [-l timeout] [-r cachesize] [-s feet]\n"
" [-T date] [-x snap-backup] files-to-dump\n"
" [-T date] [-U dumpdev] [-x snap-backup] files-to-dump\n"
" %s [-W | -w]\n", prog, prog);
exit(X_STARTUP);
}

View File

@ -1,4 +1,4 @@
.\" $NetBSD: dump_lfs.8,v 1.17 2017/06/07 15:24:50 abhinav Exp $
.\" $NetBSD: dump_lfs.8,v 1.18 2019/03/25 02:13:01 manu Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" Regents of the University of California.
@ -51,6 +51,7 @@
.Op Fl r Ar cachesize
.Op Fl s Ar feet
.Op Fl T Ar date
.Op Fl U Ar dumpdev
.Op Fl x Ar snap-backup
.Ar files-to-dump
.Nm
@ -280,10 +281,22 @@ The file
.Pa /etc/dumpdates
may be edited to change any of the fields,
if necessary.
If a list of files or subdirectories is being dumped
If the
.Fl T
option is used or if a list of files or subdirectories is being dumped
(as opposed to an entire file system), then
.Fl u
is ignored.
.It Fl U Ar dumpdev
Same as
.Fl u
but specifies the device in
.Pa /etc/dumpdates
as
.Ar dumpdev .
This option can be used with subdir dumps and with the
.Fl T
option.
.It Fl X
Prevent the log from wrapping until the dump completes, guaranteeing
a consistent backup.