[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 959
  • Last Modified:

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                                                      
0
Natspap
Asked:
Natspap
  • 5
  • 4
1 Solution
 
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





0
 
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                                                                              
0
 
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"
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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.
0
 
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.
0
 
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


0
 
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
0
 
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.
0
 
NatspapAuthor Commented:
Thanks for your prompt responses and attention to detail.  Your ranking is well deserved.
0

Featured Post

Independent Software Vendors: 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!

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now