Operating System - HP-UX
1820477 Members
3077 Online
109624 Solutions
New Discussion юеВ

Re: tar backup - multiple directories

 
SOLVED
Go to solution
MikeL_4
Super Advisor

tar backup - multiple directories

I need to backup with tar a file system that won't fit on one tape. How do I tar in one command several directories and exclude others ? and then in the second pass pick up all directories but what I backed up in the origional pass ??
8 REPLIES 8
Victor BERRIDGE
Honored Contributor

Re: tar backup - multiple directories

Hi,
For what reason do you have to backup with tar?
I would go with pax... which will do (with a bit of scripting...) exactly what you want...

All the best
Victor
Jeff_Traigle
Honored Contributor

Re: tar backup - multiple directories

Well, with some scripting, tar can do it too. However, unless there's some need to have the tapes readable by another vendor's system, why not simply use fbackup? I believe (and someone can correct me if I'm wrong) that it will automatically prompt for a second tape once the first one is full, thus negating any need to script anything regarding including/excluding directories and files.
--
Jeff Traigle
Michael Schulte zur Sur
Honored Contributor

Re: tar backup - multiple directories

Hi,

tar unfortunately does not have and exclude option. fbackup has. pax I think does not have it to.

greetings,

Michael
Govind_3
Regular Advisor

Re: tar backup - multiple directories

You could use regex to exclude the directories and do a simple ls and then pipe it to tar cvf; It would look something like this. If I were to backup all the directories other than those starting with "e to g".
ls [!e-g]* |tar cvf test.tar
-Cheers
Govind
Geoff Wild
Honored Contributor
Solution

Re: tar backup - multiple directories

Like this:

tar -cf /dev/rmt0 `cat /root/backupfiles1`

tar -cf /dev/rmt/0 `cat /root/backupfiles2`

cat /root/backupfiles1
/bin
/boot
/dev
/etc

cat /root/backupfiles2
/home
/usr
/var



Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Michael Schulte zur Sur
Honored Contributor

Re: tar backup - multiple directories

Govind,

sorry but that cannot work tar does read from stdin except when told with f -
and then you do not a tape device anymore.

greetings,

Michael
Michael Schulte zur Sur
Honored Contributor

Re: tar backup - multiple directories

HI Geoff,

if Mike does not want to exclude a dir from under a dir that he is backing up then your approach should work.

greetings,

Michael
MikeL_4
Super Advisor

Re: tar backup - multiple directories

Thanks