Operating System - HP-UX
1832433 Members
3202 Online
110042 Solutions
New Discussion

How can I get tar to exclude mount points

 
SOLVED
Go to solution
John D. Reaney
Advisor

How can I get tar to exclude mount points

Have a 10.20 system (K450) that has sybase - trying to do the following:
Backup /home/sybase (But want to exclude /home/sybase/dumps).

the -T option doesnt work to read from a list and I tried a find piped to tar but it complained that the file list was too long

Any ideas on where to go now.
20 REPLIES 20
Dan Hetzel
Honored Contributor

Re: How can I get tar to exclude mount points

Hi,

If you want to avoid the "argument list too long"
message, use xargs as in the following command:

find /home/sybase -xdev | xargs tar cvf /dev/rmt/0m (or any other device)

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
Rainer_1
Honored Contributor

Re: How can I get tar to exclude mount points

use pax instead:
find /home/sybase | grep -v /home/sybase/dump | pax -wf /dev/rmt/0m
Carlos Fernandez Riera
Honored Contributor

Re: How can I get tar to exclude mount points


Use pax

Pax writes tar achives file format by default and X (uppercase) flag.

Files writed with pax can be read with tar.

See man pax
unsupported
Carlos Fernandez Riera
Honored Contributor

Re: How can I get tar to exclude mount points

The fisrt reply can generate more than once recordings on tape.

You dont need to use find with pax.



Use pax -w -f /dev/rmt/.... /filesystem or directory.

unsupported
Dan Hetzel
Honored Contributor

Re: How can I get tar to exclude mount points

Rainer,

As said at the bottom of the pax manpage,
its current implementation is based on a
Posix 2 draft and HP recommends using the
current version only if absolutely
necessary.

I wouldn't save any important stuff without
being sure to be able to re-read it later.

:-((

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
John D. Reaney
Advisor

Re: How can I get tar to exclude mount points

Thanks - I am trying the xargs right now - may look at pax if this doesnt work, but this is for the dba, and she just wants to tar up her files before an upgrade, I wanted to make it easy for her.

I will post results shortly (and probly try pax anyway - am looking at the man page right now)
John D. Reaney
Advisor

Re: How can I get tar to exclude mount points

I did this:

find /home/sybase -xdev | xargs tar -cvf /home/sybase/dumps/jdr.tar

but it still put the /home/sybase/dumps files in the tar.

and yes they are diff mount points
/dev/vg0101/lvsybase1
698133 500060 128259 80% /home/sybase
/dev/vg0101/lvsybdump1
1502713 421077 931364 31% /home/sybase/dumps

the find with -xdev works I know, but havent used xargs.
Dan Hetzel
Honored Contributor

Re: How can I get tar to exclude mount points

Hi John,

As the -xdev option of find visits the mount
point without visinting the entries below it,
your xargs tar command receives the /home/sybase/dumps as input.

Adding flag -type f will do the job.

Your command should now look like:

find /home/sybase -type f -xdev | xargs ....

I should have tested the command before posting ;-)

Hope this helps

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
James R. Ferguson
Acclaimed Contributor

Re: How can I get tar to exclude mount points

John:

An alternative approach would be to use 'fbackup' with a graph that includes and excludes the directories you require. See the man pages (1M) for fbackup/frestore. This forum contains a great deal of good discussion regarding fbackup if you are unfamilar with it, too.

...JRF...
Kofi ARTHIABAH
Honored Contributor

Re: How can I get tar to exclude mount points

John:

you would want to use the find however, if there are other mount points below /home/sybase that you would like to include, -xdev would not help you. Also, if /home/sybase/dump is not a file system, it would not help you. You could try a combination of find and grep -v as follows:

find /home/sybase -print | grep -v "/home/sybase/dump/*" | xargs ....

Good luck

nothing wrong with me that a few lines of code cannot fix!
John D. Reaney
Advisor

Re: How can I get tar to exclude mount points

I tried the find with the -type f option but the tar file does not contain all the files, gonna try this and see what i get:

find /home/sybase -xdev -exec tar -cvf /home/sybase/dumps/out.tar {} ;

maybe maybe.. what do you think
Dan Hetzel
Honored Contributor

Re: How can I get tar to exclude mount points

John,

I don't understand why your tar file doesn't
include all the files.

Does the command find /xxx -type f -xdev
show all needed files?
Do you have the right permissions to read
all the files?

Dan

PS: adding the -exec tar won't help because
the mountpoint is still visited.
As soon as tar receives a directory as
argument, all files below it are archived.
That's why I added th e-type f option.

Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
John D. Reaney
Advisor

Re: How can I get tar to exclude mount points

I know I dont understand either - driving me nuts. I am now combining a few responses and trying this..

find /home/sybase print |grep -"/home/sybase/dumps" | xargs tar -cvf /home/sybase/dumps/sybdump.tar

The find command on its own (find /home/sybase print |grep -"/home/sybase/dumps" ) works fine - however the tar was creating files in that dir when I used the -xdev on the find.

Will update in a few when job finishes and I thank all of you for you help..
John D. Reaney
Advisor

Re: How can I get tar to exclude mount points

OK more perplexing stuff:

when i run: find /home/sybase print |grep -v "/home/sybase/dumps" | grep dum i dont get /home/sybase/dumps but when I change teh grep dum to xargs tar cvf /home/sybase/dumps/sybas.tar it wants to tar the /home/sybase/dumps filesystem.....
Devbinder Singh Marway
Valued Contributor

Re: How can I get tar to exclude mount points

DO you have to use tar , can you use cpio
cd dir
find . -xdev -print | cpio -ovcdumB > /dev/rmt/??

Seek and you shall find
John D. Reaney
Advisor

Re: How can I get tar to exclude mount points

what command to extract then if is use cpio o
Dan Hetzel
Honored Contributor

Re: How can I get tar to exclude mount points

Or, if you want to copy the whole tree,
without crossing the mount point:

find /home/sybase -type f -xdev | cpio -pdvum

v is optional, as it gives verbose info on the files copied.

Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
Devbinder Singh Marway
Valued Contributor
Solution

Re: How can I get tar to exclude mount points

cd into / and issue cpio -ivcdumB
nb: < to read in > to send out
i to restore o to output / backup

Seek and you shall find
Kevin Ernst
Regular Advisor

Re: How can I get tar to exclude mount points

If you don't need to exchange these tapes with another site, why not use GNU tar. It can exclude directories specified on the command line (using the --exclude option), and has a host of other wonderful features.

You can download a precompiled binary in SD depot format from a HP-UX Porting and Archive Center mirror in your neighborhood (like http://hpux.cae.wisc.edu ). The documentation for GNU tar is very thorough, though you will need to install the 'texinfo' depot as well, as it is in 'texinfo' format. (A terse 'man' page is included as well, for quick reference.)
Kevin Ernst
Regular Advisor

Re: How can I get tar to exclude mount points

Actually, I think you only run into the compatibility issues between GNU and other 'tar's when you get into multi-volume backups, odd blocking factors, block compression, and volume labels and such, which other vendors' 'tar's won't understand. There is an entire section in the GNU tar 'texinfo' documentation on portability guidelines.

Fbackup/frestore is another option, of course, but that would exclude any possibility of restoring the backup sets on some other (non-HP-UX) platform. Which may not even be a concern at your site...