From owner-freebsd-questions@FreeBSD.ORG Mon Apr 8 00:10:29 2013 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D9E038C2 for ; Mon, 8 Apr 2013 00:10:29 +0000 (UTC) (envelope-from vogelke@hcst.net) Received: from beta.hcst.com (beta.hcst.com [192.52.183.241]) by mx1.freebsd.org (Postfix) with ESMTP id A91C0889 for ; Mon, 8 Apr 2013 00:10:29 +0000 (UTC) Received: from beta.hcst.com (localhost [127.0.0.1]) by beta.hcst.com (8.14.3/8.14.3/Debian-9.4) with ESMTP id r3807klO007454 for ; Sun, 7 Apr 2013 20:07:46 -0400 Received: (from vogelke@localhost) by beta.hcst.com (8.14.3/8.14.3/Submit) id r3807kax007453; Sun, 7 Apr 2013 20:07:46 -0400 Received: by kev.msw.wpafb.af.mil (Postfix, from userid 32768) id 2875ABF92; Sun, 7 Apr 2013 20:07:17 -0400 (EDT) To: questions@freebsd.org In-reply-to: <515E23E2.1090906@a1poweruser.com> (message from Joe on Thu, 04 Apr 2013 21:07:46 -0400) Subject: Re: using pax command for archive & restore Organization: Array Infotech X-Disclaimer: I don't speak for the USAF or Array Infotech. X-GPG-ID: 1024D/711752A0 2006-06-27 Karl Vogel X-GPG-Fingerprint: 56EB 6DBF 4224 C953 F417 CC99 4C7C 7D46 7117 52A0 References: <515E23E2.1090906@a1poweruser.com> Message-Id: <20130408000718.2875ABF92@kev.msw.wpafb.af.mil> Date: Sun, 7 Apr 2013 20:07:17 -0400 (EDT) From: vogelke+unix@pobox.com (Karl Vogel) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: vogelke+unix@pobox.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Apr 2013 00:10:29 -0000 >> On Thu, 04 Apr 2013 21:07:46 -0400, >> Joe said: J> I archive using the pax command like this J> pax -wzXt -x cpio -f ${archive_path_file} ${ip_path_file} ${ip_path_dir} J> and restore J> pax -rz -pe -f ${archive_path_file} J> and it restores the contents back to the same location it came from J> which is what I want. Now I would like to restore that archive file to J> a different directory. This has to be simple, but I can't see the trees J> because the forest is in the way. What am I missing here? I use pax all the time, and it's much easier to do what you want if you use it from a relative directory as part of a pipeline. When creating the archive: you% cd /some/place you% find . -depth -print | /prog/to/remove-crap | pax -wd -x cpio | gzip -c > /tmp/x.pax.gz When reading it: you% cd /other/place you% gunzip -c < /tmp/x.pax.gz | pax -r -pe Why do the compression outside of pax? Because now you have a choice of gzip -1c (fast compression), bzip2 (better compression), xz (*way* better compression), etc. If you have a ton of files to move, you can break up the list: you% cd /some/place you% mkdir /tmp/work /tmp/copy you% find . -depth -print | /prog/to/remove-crap | split - /tmp/work/x you% for file in /tmp/work/x*; do > b=`basename $file` > pax -wd -x cpio < $file | gzip -c > /tmp/copy/$b.pax.gz > scp /tmp/copy/$b.pax.gz wherever # and remove it > rm $file > done -- Karl Vogel I don't speak for the USAF or my company Why no one ever uses the Restroom on "Star Trek" #7: Special effects dept. draws a blank on Hi-tech toilets.