summaryrefslogtreecommitdiffstats
path: root/sbin/restore/main.c
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>2004-04-13 02:58:06 +0000
committergreen <green@FreeBSD.org>2004-04-13 02:58:06 +0000
commit581462d4656a457daa431e77d6ec725f56cba982 (patch)
treea1d674955b8c95633685662ea70b1c1e05573efd /sbin/restore/main.c
parenta98a06d2276b300662ee818529a9a455454f506c (diff)
downloadFreeBSD-src-581462d4656a457daa431e77d6ec725f56cba982.zip
FreeBSD-src-581462d4656a457daa431e77d6ec725f56cba982.tar.gz
Add -P arguments for dump(8) and restore(8) which allow the user to
use backup methods other than files and tapes. The -P argument is a normal sh(1) pipeline with either $DUMP_VOLUME or $RESTORE_VOLUME defined in the environment, respectively. For example, I can back up my home to three DVD+R[W]s as so: Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/ad0s2e 40028550 10093140 26733126 27% /home green# dump -0 -L -C16 -B4589840 -P 'growisofs -Z /dev/cd0=/dev/fd/0' /home
Diffstat (limited to 'sbin/restore/main.c')
-rw-r--r--sbin/restore/main.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/sbin/restore/main.c b/sbin/restore/main.c
index 9006ea5..b2ace5d 100644
--- a/sbin/restore/main.c
+++ b/sbin/restore/main.c
@@ -62,6 +62,7 @@ static const char rcsid[] =
int bflag = 0, cvtflag = 0, dflag = 0, vflag = 0, yflag = 0;
int hflag = 1, mflag = 1, Nflag = 0;
int uflag = 0;
+int pipecmd = 0;
char command = '\0';
long dumpnum = 1;
long volno = 0;
@@ -93,10 +94,9 @@ main(int argc, char *argv[])
(void)setlocale(LC_ALL, "");
- if ((inputdev = getenv("TAPE")) == NULL)
- inputdev = _PATH_DEFTAPE;
+ inputdev = NULL;
obsolete(&argc, &argv);
- while ((ch = getopt(argc, argv, "b:df:himNRrs:tuvxy")) != -1)
+ while ((ch = getopt(argc, argv, "b:df:himNP:Rrs:tuvxy")) != -1)
switch(ch) {
case 'b':
/* Change default tape blocksize. */
@@ -111,8 +111,18 @@ main(int argc, char *argv[])
dflag = 1;
break;
case 'f':
+ if (pipecmd)
+ errx(1,
+ "-P and -f options are mutually exclusive");
inputdev = optarg;
break;
+ case 'P':
+ if (!pipecmd && inputdev)
+ errx(1,
+ "-P and -f options are mutually exclusive");
+ inputdev = optarg;
+ pipecmd = 1;
+ break;
case 'h':
hflag = 0;
break;
@@ -165,7 +175,9 @@ main(int argc, char *argv[])
(void) signal(SIGTERM, SIG_IGN);
setlinebuf(stderr);
- setinput(inputdev);
+ if (inputdev == NULL && (inputdev = getenv("TAPE")) == NULL)
+ inputdev = _PATH_DEFTAPE;
+ setinput(inputdev, pipecmd);
if (argc == 0) {
argc = 1;
@@ -277,12 +289,17 @@ main(int argc, char *argv[])
static void
usage()
{
- (void)fprintf(stderr, "usage:\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n",
- "restore -i [-cdhmNuvy] [-b blocksize] [-f file] [-s fileno]",
- "restore -r [-cdNuvy] [-b blocksize] [-f file] [-s fileno]",
- "restore -R [-cdNuvy] [-b blocksize] [-f file] [-s fileno]",
- "restore -x [-cdhmNuvy] [-b blocksize] [-f file] [-s fileno] [file ...]",
- "restore -t [-cdhNuvy] [-b blocksize] [-f file] [-s fileno] [file ...]");
+ const char *const common =
+ "[-b blocksize] [-P pipecmd | -f file] [-s fileno]";
+ const char *const fileell = "[file ...]";
+
+ (void)fprintf(stderr, "usage:\t%s %s\n\t%s %s\n\t%s %s\n"
+ "\t%s %s %s\n\t%s %s %s\n",
+ "restore -i [-cdhmNuvy]", common,
+ "restore -r [-cdNuvy]", common,
+ "restore -R [-cdNuvy]", common,
+ "restore -x [-cdhmNuvy]", common, fileell,
+ "restore -t [-cdhNuvy]", common, fileell);
done(1);
}
OpenPOWER on IntegriCloud