How can i list the chunk names used in a backup?
Posted in 2008
Topics: Backup & Restore, Storage & Space Management
How can i list the chunk names used in a backup?
I am trying to write a script to automate the restore process of ontape
backups from a variety of different 'source' databases on my test box which
has a lot of disk space.
I know i can run ontape -r manually etc, and it will list the chunks from the
backup header, however i want to script it such that i can read the chunk
names first, then create (touch) those chunk names, and finally perform the
restore into those chunks.
NB: We use DIRECT_IO so this should be simple.
Thanks in advance.
I presume you mean STDIO... STDIO means no prompt, so you get no chance to
list the chunks pathnames etc...
(I presume you mean a 10.xx or 11.x engine...)
simply "turn off" STDIO which will then list the chunks for you...
To turn off "STDIO" make sure it is not set in the onconfig, and do not use
the "-t STDIO" on the ontape command.
You now have a problem because ontape is going to prompt for tape insert
etc... and you want this automated....
(I don't believe you can get the chunk info any other way (maybe archecker can
look at system tables... but I doubt it)
The Ksh way is to create a subshell that answers the prompts for you... ie
something like this
-----------------------------------------
#!/usr/bin/ksh
BACKUP=<backup filename>
TAPEDEV=<TapeDEvice>
tapecntrl() {
cr=0
# start the tape
cat <$BACKUP >$TAPEDEV &
# tell ontape its loaded
echo "y" >>$LOGFILE
echo "y"
# wait for it
wait
# rewind the tape
cat <$BACKUP >$TAPEDEV &
# lets stop
echo n
}
BACKUP=<backup filename>
TAPEDEV=/tmp/ontape_pipe
# set up pipe to control restore
rm -f $TAPEDEV
mkfifo -m 660 $TAPEDEV
chown informix:informix $TAPEDEV
# fire the backup pipe
tapecntrl | ontape -r >>$LOGFILE 2>&1
wait
-------------------------------
Oh of course the rootdbs in the 'new' onconfig is the set to the 'original'
rootdbs path...
Tell me how you get on... (And wouldn't it be nice if ontape had an option to
extract this info using stdio )
Hi, thanks.
Your suggestions gave me an idea;
I realised that I can get the header info by setting TAPEDEV to the local
ontape backup file, running ontape -r and passing in auto answers, then
finally piping the output through grep and lastly dumping into a file.
SPACES=/tmp/dbspaces
CHUNKPATHS=/tmp/chunkpaths
# Find the dbspaces and chunk paths being used in the tape backup
ontape -r < /opt/informix/database_restore.inputs | grep ' informix ' | awk
{'print $8'} > $SPACES
ontape -r < /opt/informix/database_restore.inputs | grep PO-B | awk {'print
$7'} > $CHUNKPATHS
Contents of 'database_restore.inputs';
y
n
n
This now means I have two files containing purely just a list of the chunks
and dbspaces used in the backup file. I have used this list to touch a set of
cooked chunks for restoring.
The next challenge I have now is I want to have those chunks exist in a
directory which is different to that on site.
E.g. on the production server where the ontape backup to file was taken;
chunks reside in /data/, however on my test box I want to have those chunks
exist in /data/customername/.
When I try the restore however, ontape moans that ./rootdbs is not the same as
/data/rootdbs etc.
As dirty work around I wrote my script to create a bunch of temporary symlinks
in /data/ pointing to /data/customername/, perform the restore and then drop
the symlinks, but this is still not working quite right and the restore assert
fails!
Is there a special ontape parameter i can pass maybe that says, ignore what
you think and just do the restore?
Symbolic links works for me!
Historical best practices had all chunks as symbolic links, so you could move
chucks. It is obviously still a valid, worthwhile practice.
And no, there is no special parameter to make ontape ignore the rootdbs...
By the way, I wrote a similar script but used dup_spaces.sh off iiug
repository to first generate the chunks from my source database, then I used
sed to replace the common lead pathnames to fit my target environment... I had
thought of the same idea as you but had onbar in use as well (and onbar can't
list the chunks... Now would't it be nice if...)
Robert
Hi Robert, Well i got it all working. The failures turned out to be due to a completely unrelated simple issue. I have now got the script to ask which customer you are trying to restore, builds all the correct environment variables etc, asks where your backup is, checks it, updates onconfig with the tape location, reads that database version the backup was from, (Haven't managed to get the correct engine to be auto switched in yet), reads the chunks used, creates them in a customer specific directory, creates the needed symlinks and then finally does the restore. It is almost complete, still a bit rough and ready but it works. I wanted to do this to help speed things up because every time we need to upgrade a customer we have to take a copy and simulate the upgrade. I am a newbie here so i didn't realise there were code samples people have posted. I will go and have a look right now :) Thank you for your thoughts :) Andy