1849181 Members
8774 Online
104041 Solutions
New Discussion

Another tar question

 
SOLVED
Go to solution
Kelli Ward
Trusted Contributor

Another tar question

Hi all,
I need to make a tar backup and exclude a number of files. I know the X option will do this but is not working properly for me.
Could some helpful soul let me know the best syntax for excluding files from a tar backup?
THanks,
Kel
The more I learn, the more I realize how much more I have to learn. Isn't it GREAT!
10 REPLIES 10
Bill Hassell
Honored Contributor

Re: Another tar question

-X option in tar? Can't find it in HP-UX man pages, perhaps it is something found in Solaris. You'll probably have to use regular expressions to exclude certain file patterns. Otherwise, cpio and pax accept stdin file lists, and fbackup has options to include and exclude files with multiple specifications allowed.


Bill Hassell, sysadmin
Jeff Machols
Esteemed Contributor

Re: Another tar question

Kel,

Are you sure about that -X option for tar? I am sure that exists. If you have to use tar you may need to pipe it through find.
Thom Cornwell
Frequent Advisor

Re: Another tar question

From SUN Solaris 2.8 tar manual page
X Exclude. Use the exclude-file argument as a file containing a list of relative path names for files (or directories) to be excluded from the tarfile when using the functions c, x, or t. Be careful of trailing white spaces. Also beware of leading white spaces,since, for each line in the excluded file, the entire line (apart from the newline) will be used to match against the initial string of files to exclude. Multiple X arguments may be used, with one exclude-file per argument. In the case where included files (see -I include-file option) are also specified, the excluded files take precedence over all included files. If a file is specified in both the exclude-file and the include-file (or on the command line), it will be excluded.
S.K. Chan
Honored Contributor

Re: Another tar question

In HP-UX, you probably can do something like this ..

$ cd dirA
$ ls|grep -v aug|xargs tar cvf /dev/rmt/0m

The above will exclude filename with "aug" string in it.
Justo Exposito
Esteemed Contributor

Re: Another tar question

Hi Kelly,

I think that the best way is using a find in order to obtain an intermediate file and then in this file exclude the path's that you don't want to backup, and us it as input for tar.

I don't find -X option in man tar too.

Regards,

Justo.
Help is a Beatiful word
Chris Vail
Honored Contributor

Re: Another tar question

About a bazillion years ago, there was a third party product called ctar that permitted an 'exclude' flag. I don't know if it has been ported to HP/ux, but I suspect so. The nice people at unitrends: http://www.unitrends.com sell it. It worked pretty good for some other flavors of Unix that I've used.

Barring that, you might want to try a hint I got here a couple of weeks ago. Assuming that you want to create "destfile" and the text file with the filenames in it is "filelist" the command:
tar cvf destfile `cat filelist`
works pretty well also.
Kelli Ward
Trusted Contributor

Re: Another tar question

You guys may be right, I've been playing with a few versions of Unix lately and I may be mixing up my versions.
What would be the best HP-UX way to exclude files from a tar backup?
Syntax would be great.
Thanks,
Kel
The more I learn, the more I realize how much more I have to learn. Isn't it GREAT!
Jeff Machols
Esteemed Contributor

Re: Another tar question

maybe something like this

tar -cvf tarfile `find . -print | egrep -vx 'file1|file2|..|fileX'
harry d brown jr
Honored Contributor

Re: Another tar question

Kelli,

You can get GNU's tar, which will do as you ask:

http://hpux.connect.org.uk/hppd/hpux/Gnu/tar-1.13.25/

and documentation from GNU:

http://www.gnu.org/manual/tar/html_mono/tar.html#SEC39

live free or die
harry
Live Free or Die