Solved

tar command

Posted on 2004-04-19
15
38,835 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 61

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
 
LVL 61

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 61

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 61

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 61

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 61

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
FTP on FreeBSD server 2 114
Write an app 10 67
Cygwin VIM in WIndows 2007: Unable to copy text to Windows 10 60
How can i set a Environment Variable in my Unix script ? 3 52
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
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.

864 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now