Re: (Another) ontape to recover from a FIFO pipe
Posted in 2005
We've had a backup script using ontape since before I started working
here. Since we never had a restore script in our system, I started
working on it. I found some help from Tim Brown's shell script example
in the user group. The (cat...cat...)& portion was particularly
helpful.
I like to see a lot of examples in the user group, so since this
solution does work for me (though there could be more error checking,
etc), I thought I'd pass along the restore script. Use at your own
risk.
SunOS 5.7
IDS 9.30.UC2
Note that I'm not sure why the ^M is used for the return, rather than
just a carriage return, but that's the way it was in the backup routine
that I started from and it worked, so I didn't make a change. BTW,
when I edited the file in vi, after I was already in insert mode, I had
to use <CTL>v<CTL>m to get the ^M to show up as a single character.
Hope this helps. Comments appreciated.
-----------------------------------------------------------------------
#!/usr/bin/ksh
# Setup PATH, INFORMIXDIR, INFORMIXSERVER, etc.
pipe_name=/tmp/dbpipe
if [ $# -ne "1" ]
then
echo "Invalid number of parameters for $0"
echo "Usage: $0 <backupfilname>"
exit
else
backupfile=$1
fi
# Make sure the database is shutdown
onmode -ky
# Open the pipe
mknod $pipe_name p
# Write the backup file to the pipe. Because of tape rewind we
# know that the pipe will break when we begin the restore, so we
# automatically restart writing the backup file to the pipe as
# soon as it fails. -- taken from Tim Brown's example
(
cat $backupfile > $pipe_name || \\
cat $backupfile > $pipe_name
) &
# Start the database server restore
#
# Respond to prompts:
# ^M - Mount device and press enter
# y - Continue Restore?
# n - Backup Logical Logs?
# n - Restore Level 1 archive?
# n - Restore Logical Logs?
ontape -r << EOF^M
y
n
n
n
EOF
# Not sure if this is necessary, but shows server status
# as it continues recovery mode through Quiescent mode
online=`onstat - | egrep Quiescent`
while [[ X${online} = X ]]
do
echo "Server still in Recovery mode, sleep and then check again..."
sleep 5
online=`onstat - | egrep Quiescent`
done;
-- Now that we're done recovering, force to multi-user mode
onmode -m
-----------------------------------------------------------------------
timothy.a.brown@marconi.com wrote:
> Hi Jacob,
>
> Here's an example that uses pipes and compression. Use at your own
risk,
> and assume it is pseudocode and has not been tested. I wrote it
quickly
> last week to help Martha (IIUG member) with the same sort of issue.
Please
> let me know your thoughts and suggestions. I'm posting to the IIUG
because
> of the many requests to do what you are wanting to do...
>
> #!/bin/sh -e
> #...
> #... Remember to setup your Informix environment variables
> #...
> FILEMB=100 # Mbytes maximum per file created
> RDIR=/local/db_tmp/Martha # location of compress--split files
> TLINK=/tmp/tapedev.link # onconfig: TAPEDEV /tmp/tapedev.link
> # onconfig: TAPEBLK 8 # streams
> # onconfig: TAPESIZE 2000000000 # big
> touch $TLINK # temporary for testing,,,
>
> if [ 1 -eq 1 ]; then
> #.....................Perform the Backup
> #... The database should be online before running :-)
> #... The backup can be run in the background :-)
> #...
> rm $TLINK # remove link
> mknod $RDIR/split.pipe p # make a pipe
> mknod $RDIR/backup.pipe p # make a pipe
> ln -s $RDIR/backup.pipe $TLINK # create link to the pipe
> chown -R informix:informix $RDIR # informix ownership to contents
> chmod 660 $RDIR/*.pipe # read/write permission to pipes
> compress -fv - < $RDIR/backup.pipe > $RDIR/split.pipe &
> split -b${FILEMB}m -a 5 - $RDIR/file_ < $RDIR/split.pipe &
> echo "\\n\\n" | ontape -s -L 0 # backup program
> rm $RDIR/*.pipe # cleanup pipes
> touch $TLINK # temporary for testing,,,
> fi
>
> if [ 1 -eq 0 ]; then
> #.....................Perform the Restore
> #... The database should be offline before running :-)
> #... The restore should be run in the foreground :-)
> #...
> rm $TLINK # remove link
> mknod $RDIR/restore.pipe p # make a pipe
> ln -s $RDIR/restore.pipe $TLINK # create link to the pipe
> chown -R informix:informix $RDIR # informix ownership to contents
> chmod 660 $RDIR/restore.pipe # read/write permissions to pipe
> ( # work-around for "rewind"
> cat `ls -1 $RDIR/file_[a-z]*` | uncompress -c > $RDIR/restore.pipe ||
\\
> cat `ls -1 $RDIR/file_[a-z]*` | uncompress -c > $RDIR/restore.pipe
> )&
> echo "wait 5 seconds before replying to prompts"
> ontape -r # restore program
> rm $RDIR/*.pipe # cleanup pipes> fi
>
> Kind Regards,
> -Tim
>
>
>
>
> "Art S. Kagel"
> <kagel@bloomberg.n To:
informix-list@iiug.org
> et> cc:
> Sent by: Subject: Re:
(Another) ontape to recover from a FIFO pipe
> owner-informix-lis
> t@iiug.org
>
>
> 10/13/2004 05:28
> PM
> Please respond to
> kagel
>
>
>
>
>
>
> On Wed, 13 Oct 2004 16:49:24 -0400, Jacob Salomon wrote:
>
> You cannot recover from a pipe. Ontape opens the 'tape' file, reads
the
> reserved pages, performs some calculations, closes the 'tape' file,
and
> reopens expecting that the tape has rewound.
> Art S. Kagel
>
>
> > Informix IDS 7.23 (Go ahead and laugh - I agree with you)
> >
> > Hi Family.
> >
> > I have been researching ways to archive to a named pipe. I see from
> > researching this newsgroup that I am far from the dfirst person to
try
> this.
> > By playing with the TAPEBLK size, I came up with 128K as an ideal
buffer
> > size for backups - it backed up a 140GB system in under 2 hours.
> >
> > The Unix SA created a 200GB "large file" file system while I
created a
> FIFO
> > and set TAPEDEV to reference it. I also set the TAPESIZE to a
billion
> (K).
> > All set up.
> >
> > I backed up by starting a DD command to read from the FIFO and
write to a
> > flat file. The I started the ontape -s -L 0. Like I said above, it
was
> done
> > in under 2 hours using the 128K block size.
> >
> > Now how about recovery? Well, I started the ontape -r in one
window. $
> > ontape -r> > P