Operating System - HP-UX
1819801 Members
3311 Online
109607 Solutions
New Discussion юеВ

exclude a directory using tar command

 
SOLVED
Go to solution
Ng Pea Har
Occasional Advisor

exclude a directory using tar command

How can I exclude a directory when using tar command?
9 REPLIES 9
Thierry Poels_1
Honored Contributor

Re: exclude a directory using tar command

Not possible.
Tar does not have this functionality. You might want to have a look at fbackup which allows you to include & exclude directory paths.
good luck,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Ng Pea Har
Occasional Advisor

Re: exclude a directory using tar command

I need to make a tar file at the same time exclude a directory from it. How can I make use of find . -depth -print | grep -v with tar to exclude the directory that I do not want?
Stefan Farrelly
Honored Contributor

Re: exclude a directory using tar command


You need to download and install gnu tar (gtar) from HP's software porting centre. It allows you to exclude directories. We use it and it works fine.

http://hpux.connect.org.uk/hppd/hpux/Gnu/tar-1.13.18/
Im from Palmerston North, New Zealand, but somehow ended up in London...
Carlos Fernandez Riera
Honored Contributor

Re: exclude a directory using tar command

or try pax...
unsupported
Thierry Poels_1
Honored Contributor

Re: exclude a directory using tar command

hi,
standard tar cannot cope with this.
You will have to look at other options like other also mentionned : gnu tar, pax, fbackup, cpio, ...
regards,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Vincenzo Restuccia
Honored Contributor

Re: exclude a directory using tar command

Not possible!
Ng Pea Har
Occasional Advisor

Re: exclude a directory using tar command

How can I use pax to exclude a directory?
Thierry Poels_1
Honored Contributor

Re: exclude a directory using tar command

find /dir | grep -v ignoredir | pax -w -v > /dev/rmt/0m
(customize to your needs)
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Davide Depaoli
Occasional Advisor
Solution

Re: exclude a directory using tar command

move into directory you want to backup
cd /dir

list all files and subdirs into a list file
ls -1 > tar_list

edit tar_list and remove directory/files you don't want to backup
vi tar_list
delete undesired entries

make a tar backup
tar cv `cat tar_list`

It's work !

regards Davide