From owner-freebsd-bugs Thu Sep 7 9:10:15 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id C289237B424 for ; Thu, 7 Sep 2000 09:10:00 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id JAA60689; Thu, 7 Sep 2000 09:10:00 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from public.ndh.com (public.ndh.net [195.94.90.21]) by hub.freebsd.org (Postfix) with ESMTP id D286937B424 for ; Thu, 7 Sep 2000 09:05:14 -0700 (PDT) Received: from elan.firekeys.org (port2089.duesseldorf.ndh.net [195.227.37.89]) by public.ndh.com (8.9.3/8.8.0) with ESMTP id SAA26229 for ; Thu, 7 Sep 2000 18:05:06 +0200 (MET DST) Received: from esprit.firekeys.org (esprit.firekeys.org [192.168.1.101]) by elan.firekeys.org (8.11.0/8.11.0) with ESMTP id e87G5oX01608 for ; Thu, 7 Sep 2000 18:05:50 +0200 (CEST) (envelope-from sm@firekeys.org) Message-Id: <200009071605.e87G5o001105@esprit.firekeys.org> Date: Thu, 7 Sep 2000 18:05:50 +0200 (CEST) From: s.moeding@ndh.net Reply-To: s.moeding@ndh.net To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/21093: New option for restore (patch) Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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 #include +#include #include #include #include @@ -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