Solved

tar command

Posted on 2004-04-19
15
38,847 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
  • 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
CPU monthly average? 12 131
remove a combination of patterns from a file 15 70
SCP a file to multiple machines using a script 4 66
awk sed 8 64
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…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.

840 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