Re: how can I "find xyz | xargs tar" ... like gtar

Previous thread: Re: Does OpenBSD support Hebrew? by Christian Weisgerber on Sunday, September 23, 2007 - 11:21 am. (3 messages)

Next thread: Package Dependency Problem with glitz and X by David on Sunday, September 23, 2007 - 2:16 pm. (4 messages)
From: Didier Wiroth
Date: Sunday, September 23, 2007 - 11:53 am

Hello,
I would like to tar and compress my ports dir without the following 2 directories:
a) distfiles
b) packages

Here is a gtar command I used that works well:
cd /usr && gtar -czpf ~/test.tar.gz --exclude=packages --exclude=distfiles ports

Actually I would like to do the same with the default openbsd tools ... but I can't :-((

I tried different commands ... but without success .... it does not work.
Using "find ... | xargs tar ..." does not work as expected, as it looks like xargs invokes the tar command multiple times. 
As a result, the ports.tar.gz file is overwritten and incomplete.

I tried a lot of combinations like:
cd /usr
find ports/ ! \( -type d -name packages -maxdepth 1 \) -and !  \( -type d -name distfiles -maxdepth 1 \) -print \
| xargs tar -czpf ~/ports.tar.gz;
This does not work .... the ports.tar.gz file is overwritten multiple times and at the end it is incomplete.
I also tried pax or tried to redirect the find command in a file ( find .. > files.txt), and use "cat files | xargs tar ..." same result :-(

How can achive my goal with the standard openbsd files (without installing gtar!)?

Thank you very much
didier

From: Antoine Jacoutot
Date: Sunday, September 23, 2007 - 11:59 am

Read tar(1) and have a look at the "-s" flag.

-- 
Antoine

From: Mats O Jansson
Date: Sunday, September 23, 2007 - 12:41 pm

When I started to do backup many years ago it was a find piped to cpio.

so i think you could replace the xargs tar with some variant of
cpio -o -H ustar which should generate a tar archive. 

but i havn't tested... So look at the switches for cpio.


From: Han Boetes
Date: Sunday, September 23, 2007 - 12:23 pm

Well that's not so hard...

~/.tmp% ls -la     
total 2190
drwx------  3 han users    512 Sep 23 21:19 .
drwx------ 18 han users   1536 Sep 23 21:20 ..
-rwxr-xr-x  1 han users 908581 Sep  7 18:55 configure
-rwxr-xr-x  1 han users 908228 Sep  7 18:51 configure.orig
-rw-r--r--  1 han users    596 Sep  7 18:48 irssi.configure.in.patch
-rw-------  1 han users    243 Sep 23 20:59 mailtmp
drwx------  2 han users    512 Sep 22 18:58 mc-han
-rw-r--r--  1 han users   3214 Aug 21 08:53 mutt-haddock-1000-26618-424
~/.tmp% tar czf foo.tgz $(find . ! -name mc-han ! -name .)
~/.tmp% tar tvzf foo.tgz 
-rw-------  1 han      users          243 Sep 23 20:59 ./mailtmp
-rw-r--r--  1 han      users         3214 Aug 21 08:53 ./mutt-haddock-1000-26618-424
-rwxr-xr-x  1 han      users       908581 Sep  7 18:55 ./configure
-rw-r--r--  1 han      users          596 Sep  7 18:48 ./irssi.configure.in.patch
-rwxr-xr-x  1 han      users       908228 Sep  7 18:51 ./configure.orig

Got it? :-)


# Han

From: Marc Espie
Date: Sunday, September 23, 2007 - 3:23 pm

man xargs

You probably want to override the limit with xargs -n.

But actually, since tar is recursive, you probably just want to grab first
level names and prune out distfiles and packages.

Or, if you really must figure out every filename you want to archive (say,
if you want to avoid CVS or working directories), look up tar -I.

Previous thread: Re: Does OpenBSD support Hebrew? by Christian Weisgerber on Sunday, September 23, 2007 - 11:21 am. (3 messages)

Next thread: Package Dependency Problem with glitz and X by David on Sunday, September 23, 2007 - 2:16 pm. (4 messages)