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
Read tar(1) and have a look at the "-s" flag. -- Antoine
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.
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
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.
