Add a new "-S" flag to dump to allow it just print out dump estimate

size and then exit.

PR:		bin/35450
Submitted by:	Mark Hannon <markhannon@optushome.com.au>
Obtained from:	NetBSD
MFC after:	1 week
This commit is contained in:
Ian Dowse 2002-03-01 20:54:23 +00:00
parent b3aeda3f1f
commit 9ac0768d74
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=91540
2 changed files with 20 additions and 5 deletions

View File

@ -33,7 +33,7 @@
.\" @(#)dump.8 8.3 (Berkeley) 5/1/95 .\" @(#)dump.8 8.3 (Berkeley) 5/1/95
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd July 9, 2001 .Dd March 1, 2002
.Dt DUMP 8 .Dt DUMP 8
.Os .Os
.Sh NAME .Sh NAME
@ -42,7 +42,7 @@
.Nd filesystem backup .Nd filesystem backup
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl 0123456789acknu .Op Fl 0123456789acknSu
.Op Fl B Ar records .Op Fl B Ar records
.Op Fl b Ar blocksize .Op Fl b Ar blocksize
.Op Fl D Ar dumpdates .Op Fl D Ar dumpdates
@ -194,6 +194,9 @@ If this amount is exceeded,
prompts for a new tape. prompts for a new tape.
It is recommended to be a bit conservative on this option. It is recommended to be a bit conservative on this option.
The default tape length is 2300 feet. The default tape length is 2300 feet.
.It Fl S
Display an estimate of the backup size and the number of
tapes required, and exit without actually performing the dump.
.It Fl T Ar date .It Fl T Ar date
Use the specified date as the starting time for the dump Use the specified date as the starting time for the dump
instead of the time determined from looking in instead of the time determined from looking in

View File

@ -99,6 +99,7 @@ main(argc, argv)
char *map; char *map;
int ch; int ch;
int i, anydirskipped, bflag = 0, Tflag = 0, honorlevel = 1; int i, anydirskipped, bflag = 0, Tflag = 0, honorlevel = 1;
int just_estimate = 0;
ino_t maxino; ino_t maxino;
char *tmsg; char *tmsg;
time_t t; time_t t;
@ -119,9 +120,9 @@ main(argc, argv)
obsolete(&argc, &argv); obsolete(&argc, &argv);
#ifdef KERBEROS #ifdef KERBEROS
#define optstring "0123456789aB:b:cd:f:h:kns:T:uWwD:" #define optstring "0123456789aB:b:cd:f:h:kns:ST:uWwD:"
#else #else
#define optstring "0123456789aB:b:cd:f:h:ns:T:uWwD:" #define optstring "0123456789aB:b:cd:f:h:ns:ST:uWwD:"
#endif #endif
while ((ch = getopt(argc, argv, optstring)) != -1) while ((ch = getopt(argc, argv, optstring)) != -1)
#undef optstring #undef optstring
@ -182,6 +183,10 @@ main(argc, argv)
tsize = numarg("tape size", 1L, 0L) * 12 * 10; tsize = numarg("tape size", 1L, 0L) * 12 * 10;
break; break;
case 'S': /* exit after estimating # of tapes */
just_estimate = 1;
break;
case 'T': /* time of last dump */ case 'T': /* time of last dump */
spcl.c_ddate = unctime(optarg); spcl.c_ddate = unctime(optarg);
if (spcl.c_ddate < 0) { if (spcl.c_ddate < 0) {
@ -420,6 +425,13 @@ main(argc, argv)
tapesize, fetapes); tapesize, fetapes);
} }
/*
* If the user only wants an estimate of the number of
* tapes, exit now.
*/
if (just_estimate)
exit(0);
/* /*
* Allocate tape buffer. * Allocate tape buffer.
*/ */
@ -508,7 +520,7 @@ usage()
#ifdef KERBEROS #ifdef KERBEROS
"k" "k"
#endif #endif
"nu] [-B records] [-b blocksize] [-D dumpdates]\n" "nSu] [-B records] [-b blocksize] [-D dumpdates]\n"
" [-d density] [-f file ] [-h level] [-s feet] " " [-d density] [-f file ] [-h level] [-s feet] "
"[-T date] filesystem\n" "[-T date] filesystem\n"
" dump [-W | -w]\n"); " dump [-W | -w]\n");