Solved

tar command

Posted on 2004-04-19
15
38,858 Views
Last Modified: 2013-11-17
Hi All,

Our system is AIX 5.1.

1. I wrote a srcipt to tar only FOUR directories:
 
tar -cvf /dev/rmt0.1 / >> /logs/coldbackup
tar -cvf /dev/rmt0.1 /usr >> /logs/coldbackup
tar -cvf /dev/rmt0.1 /var>> /logs/coldbackup
tar -cvf /dev/rmt0.1 /opt >> /logs/coldbackup

However at the end, I found it tar ALL the directories in my system, such as /tmp, /abc, /def, ....etc. So what's the problem? I shouldn't put tar / (root) in the script? if there is alternative method (command) to backup root file system only and exclude any mounted file system and the link to them?

2. I saw there is some limitation on using tar to backup the file size which is bigger than 2 G, so how to solve this?

Thanks

0
Comment
Question by:terrywong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 3
  • +2
15 Comments
 
LVL 45

Expert Comment

by:sunnycoder
ID: 10865957
Hi terrywong,

What version of tar are you using ?

tar -cvf <archive name>.tar <directory to archive>

is the normal way of using tar command ... It does not look same to me

For your second problem, I think recompiling your tar program with large file support should solve the problem

Sunnycoder
0
 
LVL 62

Expert Comment

by:gheist
ID: 10865989
AIX has mksysb command, best run for smit, and backup command for other volume groups.
tar is somewhat limited (by posix), same is true about pax or cpio..., and they never back up hdisk5 (boot volume), so you will end up with unusable backup data.

0
 

Author Comment

by:terrywong
ID: 10865990
thank you for the reply.
What I am trying to do is to put all the files into a non-rewind tape drive directly.
tar -cvf <device> <directory to archive> >> logs

Terry
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 62

Expert Comment

by:gheist
ID: 10866003
sunny: wt?.... tar format has 32-bit block counter, any other "support" is non standard.
same about longer file names.
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 10866005
I do not think tar produces the archive on atandard output ... You need to specify the filename for the archive (I am not sure if it is the same on AIX) ... try using the format

tar -cvf backup.tar main_dir

and then copy it the tape
0
 
LVL 62

Expert Comment

by:gheist
ID: 10866020
tar cvf - /wherever | gzip -9 | dd of=/dev/rmt0.6

terry: avoid gcc compiler, it does not work with some aix linker versions, gtar or star make tar files which are not correctly processed by system tar, same about sed awk etc tools.
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 10866025
Gheist I have not used much of unix but loads of linux ... Recent versions of kernels and compilers came out with large file support which allows you to overcome limitation of 2Gb ... This support is standardized for sure ... If you wish to verify, check the man pages for recent releases of glibc (man 2 open for example) ... However for enabling these options to be used, programs need to be compiled for LFS support enabled through compiler switches
0
 
LVL 62

Expert Comment

by:gheist
ID: 10866486
hello - tar format limits block count in file.... large file support enables to create huge tar files
0
 
LVL 20

Expert Comment

by:Gns
ID: 10867432
Sunny, tar will happily write directly to tape. There is no probblem (apart from the obvious need to _exlude_ things instead of _including everything_ a couple of times:-). GNU tar isn't necessarily POSIX, so will "overcome" the POSIX header limitations.
Gheist, for 5.1 the "tar limit" might be 2GiB ("enforeced" in  the tar header), on 5.2 it's up to 8 GiB/archived file... "ustar" header... empirically tested to work too:-).

But the correct answer has already been given (by gheist): You should be using mksysb to back up the rootvg, and possibly backup to dump any othe volume groups. Has the added bonus of drastically simplifying restore.

If for some reason you still want to make a tar dump, you should perhaps look at getting GNU tar, since the OS version will not preserve sparce files (amongst other things)... You can get one prebuilt from http://www.bullfreeware.com/download/aix43/gnu.tar-1.13.0.0.exe (following the 5.1 link, you get the 4.3 one. Go figure:).
You might want to explore the possibilitys of the -C and --one-file-system with that one... Removes the need to create "exlude lists".

-- Glenn
0
 
LVL 62

Accepted Solution

by:
gheist earned 100 total points
ID: 10868055
export TAPE=/dev/rmt0.1
tar c /
:-)
default is TAPE=/dev/rmt0.0

for full bakup:
1) make mksysb bootable tape
2) make volume group file backups (smit, snoop commands using Esc-6)
3) make backups from applications using raw aio volumes (db2, informix, oracle etc)
4) label tape(s) and write restore guide :-)

mt is your good friend for rewinding/forwarding tape ( read man mt )
you need eof mark on tape to start new backup.
0
 
LVL 20

Expert Comment

by:Gns
ID: 10868190
... AFAIK, #1 run from smitty is exactly the same as running "mksysb -i" :-).
Both mksysb and backup/restore have excellent well, at least OK) man-pages.
... And don't forget to take any database you have offline before dumping... Else you need a) really expensive backup system with really expensive "connector module" (like Legato Networker / BSM for Oracle:-), or b) some knowledge on how to make a script/sql-script to take "selected parts" ... "soft offline" ,,, and just dump the (at the moment) invariant db file/raw device (or do battle with rman). Going for a completely offline setup is very much simpler (especially when restoring) than any online setup.

-- Glenn
0
 
LVL 20

Expert Comment

by:Gns
ID: 10868197
BTW gheist, I thought tctl was the command and mt the conveniance ;-)

-- Glenn
0
 
LVL 62

Expert Comment

by:gheist
ID: 10869333
mt is posix , tctl and dasd is mainframe
0
 
LVL 20

Expert Comment

by:Gns
ID: 10869486
Convenience all around then :-)

-- Glenn
0
 
LVL 3

Expert Comment

by:esanchezvela
ID: 13112589
hi,

It looks a little too late to answer this anyway,..but here it goes anyway...

I belive the question is why other directories than the ones specified in the script landed in the tape the answer is because tar does not respect filesystem boundaries, if you want to backup just  / (root filesystem) I would recommend you use the backup command in the following way...

              find / -xdev -print | backup -ivf /dev/rmt0.1

that way only the rootfs will be sent to tape.

regards,
esv.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question