Date: Thu, 7 Sep 2000 18:05:50 +0200 (CEST) From: s.moeding@ndh.net To: FreeBSD-gnats-submit@freebsd.org Subject: bin/21093: New option for restore (patch) Message-ID: <200009071605.e87G5o001105@esprit.firekeys.org>
next in thread | raw e-mail | index | archive | help
>Number: 21093
>Category: bin
>Synopsis: New option for restore (patch)
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Thu Sep 07 09:10:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: Stefan Moeding
>Release: FreeBSD 4.1-STABLE i386
>Organization:
FreeBSD: The Power to Serve
>Environment:
FreeBSD 4.1-STABLE i386
>Description:
The vrestore command in Compaqs Tru64 Unix has an option '-D',
which allows the vrestore command to perform a chdir into a
given directory before performing the restore. This allows the
simpler command line
dump -0af - /usr | restore -rf - -D /mnt
instead of
dump -0 -a -f - /usr | (cd /mnt; restore -r -f -)
>How-To-Repeat:
>Fix:
The attached patch adds the '-D' flag to the restore command.
Stefan
==============================================================================
diff -ruN restore/main.c /usr/src/sbin/restore/main.c
--- restore/main.c Wed Sep 6 21:58:51 2000
+++ /usr/src/sbin/restore/main.c Thu Sep 7 17:41:01 2000
@@ -52,6 +52,7 @@
#include <protocols/dumprestore.h>
#include <err.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -99,9 +100,9 @@
inputdev = _PATH_DEFTAPE;
obsolete(&argc, &argv);
#ifdef KERBEROS
-#define optlist "b:cdf:hikmNRrs:tuvxy"
+#define optlist "b:cD:df:hikmNRrs:tuvxy"
#else
-#define optlist "b:cdf:himNRrs:tuvxy"
+#define optlist "b:cD:df:himNRrs:tuvxy"
#endif
while ((ch = getopt(argc, argv, optlist)) != -1)
switch(ch) {
@@ -117,6 +118,12 @@
case 'c':
cvtflag = 1;
break;
+ case 'D':
+ if (chdir(optarg) < 0)
+ errx(1,
+ "error accessing file system %s; %s",
+ optarg, strerror(errno));
+ break;
case 'd':
dflag = 1;
break;
@@ -293,11 +300,11 @@
usage()
{
(void)fprintf(stderr, "usage:\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n",
- "restore -i [-chkmuvy] [-b blocksize] [-f file] [-s fileno]",
- "restore -r [-ckuvy] [-b blocksize] [-f file] [-s fileno]",
- "restore -R [-ckuvy] [-b blocksize] [-f file] [-s fileno]",
- "restore -x [-chkmuvy] [-b blocksize] [-f file] [-s fileno] [file ...]",
- "restore -t [-chkuvy] [-b blocksize] [-f file] [-s fileno] [file ...]");
+ "restore -i [-chkmuvy] [-b blocksize] [-D path] [-f file] [-s fileno]",
+ "restore -r [-ckuvy] [-b blocksize] [-D path] [-f file] [-s fileno]",
+ "restore -R [-ckuvy] [-b blocksize] [-D path] [-f file] [-s fileno]",
+ "restore -x [-chkmuvy] [-b blocksize] [-D path] [-f file] [-s fileno] [file ...]",
+ "restore -t [-chkuvy] [-b blocksize] [-D path] [-f file] [-s fileno] [file ...]");
done(1);
}
diff -ruN restore/restore.8 /usr/src/sbin/restore/restore.8
--- restore/restore.8 Wed Sep 6 21:58:51 2000
+++ /usr/src/sbin/restore/restore.8 Thu Sep 7 17:31:00 2000
@@ -44,24 +44,28 @@
.Fl i
.Op Fl chkmNuvy
.Op Fl b Ar blocksize
+.Op Fl D Ar path
.Op Fl f Ar file
.Op Fl s Ar fileno
.Nm restore
.Fl R
.Op Fl ckNuvy
.Op Fl b Ar blocksize
+.Op Fl D Ar path
.Op Fl f Ar file
.Op Fl s Ar fileno
.Nm restore
.Fl r
.Op Fl ckNuvy
.Op Fl b Ar blocksize
+.Op Fl D Ar path
.Op Fl f Ar file
.Op Fl s Ar fileno
.Nm restore
.Fl t
.Op Fl chkNuvy
.Op Fl b Ar blocksize
+.Op Fl D Ar path
.Op Fl f Ar file
.Op Fl s Ar fileno
.Op file ...
@@ -69,6 +73,7 @@
.Fl x
.Op Fl chkmNuvy
.Op Fl b Ar blocksize
+.Op Fl D Ar path
.Op Fl f Ar file
.Op Fl s Ar fileno
.Op file ...
@@ -275,6 +280,11 @@
.Fl c
flag disables this check, and only allows reading a dump in the old
format.
+.It Fl D Ar path
+Specifies the destination path of where to restore the files.
+Without the
+.Fl D
+flag, the files are restored to the current directory.
.It Fl f Ar file
Read the backup from
.Ar file ;
@@ -422,6 +432,17 @@
owner, mode, and time stamps for directories.
.It Pa \&./restoresymtable
information passed between incremental restores.
+.El
+.Sh EXAMPLES
+The dump and
+.Nm restore
+commands may be used in a pipeline expression to copy file systems.
+The following are typical commands, both equivalent:
+.Bd -literal -offset indent
+dump -0 -a -f - /usr | (cd /mnt; restore -r -f -)
+dump -0af - /usr | restore -rf - -D /mnt
+.Ed
+.Pp
.El
.Sh SEE ALSO
.Xr dump 8 ,
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200009071605.e87G5o001105>
