AIX 4.1 tar command flags/syntax question

Hello Experts,
I am trying to change an existing tape backup job on my RS6000 (AIX 4.1) to include other filesystems.  Below is the current shellscript that backs up the /dbms filesystem.  Instead of backing up /dbms, I would like to back up the /u1, /home, /var and /usr filesystems.  Your help would be greatly appreciated.

cd /dbms                                                
tar -cvf/dev/rmt0 . > /tmp/backup/dbms.list 2>&1  
rc=$?                                                  
                                                       
if [ $rc -eq 0 ]                                        
then                                                    
   mail root < /home/shellscripts/backups/dbms.success
else                                                    
   mail root < /home/shellscripts/backups/dbms.failure
fi                                                      
NatspapAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

woolmilkporcCommented:
If you don't want the top level directories (e.g. u1, home, ...) in the archived path:

tar -cvf/dev/rmt0 -C /u1 . -C /home . -C /var . -C /usr .

This will give a result similar to the command you posted.

If you want to include the top level directories, but relative to ".":

cd /
tar -cvf/dev/rmt0 ./u1 ./home ./var ./usr

and finally, if you want absolute paths:

tar -cvf/dev/rmt0 /u1 /home /var /usr

wmp





Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NatspapAuthor Commented:
Thanks.  I chose Option #2 (include top level directories relative to "."). I believe my backup was successful (I see files from each of the four directories in the logfile) but I'm getting the FAILED backup message (see new script below):

cd /                                                                            
tar -cvf/dev/rmt0 ./u1 ./home ./var ./usr > /tmp/backup/u1-home-var-usr.list 2>&1
rc=$?                                                                            
                                                                                 
if [ $rc -eq 0 ]                                                                
then                                                                            
   mail root < /home/shellscripts/backups/u1-home-var-usr.success              
else                                                                            
   mail root < /home/shellscripts/backups/u1-home-var-usr.failure              
fi                                                                              
woolmilkporcCommented:
There must be an error message in the log. Your script is perfect.
Please check, there might be a bad link or the like.
If the log is too big you could redirect stderr to its own file, use "2>/path/to/errorlog" instead of "2>&1"
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

NatspapAuthor Commented:
Eyeballed error log and didn't see anything that looked like an error message, but it's a huge log so I could have missed it.  I'll redirect stderr to its own file as you suggested and see what happens.  Thanks.
NatspapAuthor Commented:
OK.  Found the problem (written to new error log):

tar: 0511-180 ./var/adm/cron/FIFO is not a valid tar file type.

Is there a way I can exclude that file from the backup?  Not a big deal I guess as long as I remember that the reason I'm getting the FAILED message is because of this.
woolmilkporcCommented:
OK,

glad you found it.

AIX' tar is a bit pedestrian when it comes to excluding files from an archive.

Simplest way is to create a file containing the full paths of files to be excluded and to give the name of this file to tar using the "-X" option.
 
So create a file named e.g. /tmp/tar.exclude containing just

./var/adm/cron/FIFO

(exactly so!)

Modify your tar command like this:

tar -X /tmp/tar.exclude -cvf/dev/rmt0 ./u1 ./home ./var ./usr > /tmp/backup/u1-home-var-usr.list 2>&1


woolmilkporcCommented:
As long as it's just for excluding FIFO files you could also try the "-d" flag (not sure if it will work in any case though):

tar -d -cvf/dev/rmt0 ./u1 ./home ./var ./usr > /tmp/backup/u1-home-var-usr.list 2>&1
NatspapAuthor Commented:
Will try the "-d" flag first and if that doesn't produce desired result will try your first suggestion.  Thanks for the quick responses.
NatspapAuthor Commented:
Thanks for your prompt responses and attention to detail.  Your ranking is well deserved.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.