Solved

tar command

Posted on 2004-04-19
15
38,830 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 61

Expert Comment

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

Expert Comment

by:Gns
Comment Utility
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
Comment Utility
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
Comment Utility
... 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
Comment Utility
BTW gheist, I thought tctl was the command and mt the conveniance ;-)

-- Glenn
0
 
LVL 61

Expert Comment

by:gheist
Comment Utility
mt is posix , tctl and dasd is mainframe
0
 
LVL 20

Expert Comment

by:Gns
Comment Utility
Convenience all around then :-)

-- Glenn
0
 
LVL 3

Expert Comment

by:esanchezvela
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

772 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

12 Experts available now in Live!

Get 1:1 Help Now