Subject RE: [ib-support] Re: maintenance strategie
Author Wilson, Fred
This is pretty straight forward. We have a application that allows the user
to set the backup and restore date and times. It interfaces via the Windows
Services API to set the scripts to run via the AT command on the IB Server.
This is all invisible to the user. The application that we provide, supplies
a nice GUI, through which they work. They strictly run the application and
they can add/delete/edit the times and dates that the backup/restore process
occurs. They can either backup or backup and restore. If they choose only
backup, we don't care if any users are connected. In the documentation with
the product, we let them know, that during backup, some users can still
work, though it will be slow. All of the mail inserters (real time database
access), will more than likely stop running, as the database will no longer
be able to get up with their request.
Since the individual sites are in control of the backup and restore dates
and times, we don't care about any users that are connected. We use the "NET
STOP" and "NET START" commands to stop and start IB, and once the "NET STOP"
command is issued, there will be no users connected ;)
Regarding checking for errors, the %ERRORLEVEL% varible is utilized.

Here's an example of a Backup and Restore script and the Backup Script:

((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((


@echo off
rem
****************************************************************************
**********
rem Setup Environment and save udf.dll. This file is essential for proper
operation of DB.
rem
****************************************************************************
**********
Echo .
Echo Performing Database backup and restore. Please wait.
Echo .
call %CmdDir%ibSet.cmd
Echo. Performing Database backup and restore. Please wait. >>
%BUDir%\ibbak.log
date /T >> %BUDir%\ibbak.log
time /T >> %BUDir%\ibbak.log

rem
****************************************************************************
**********
rem Copies of old backups are made.
rem An IB backup is called on DBDIR to BUDIR. A log entry is made.
rem
****************************************************************************
**********
set Backup0True=1
call %CmdDir%ibBackup.cmd
rem Fail and exit if the IB Backup command returned anything except 0 for
error.
if NOT %Backup0True% EQU 0 goto BACKFAIL

rem
****************************************************************************
**********
rem replace the services file so that ib will have no clients.
rem
****************************************************************************
**********
copy c:\winnt\system32\drivers\etc\services
%CmdDir%BHSOFTWARE\SYSFILES\SERVICES.ORG
copy %CmdDir%BHSOFTWARE\SYSFILES\SERVICES
c:\winnt\system32\drivers\etc\services

rem
****************************************************************************
**********
rem Wait 5 minutes to have the clients time out and then shutdown the
database
rem
****************************************************************************
**********
Echo Database is shutting down.
Echo This will take up to 5 minutes. Please wait...
%CmdDir%BHSOFTWARE\SYSFILES\Sleep.exe 300

rem
****************************************************************************
**********
rem Stop IB
rem
****************************************************************************
**********
net stop "InterBase Guardian"
net stop "InterBase Server"

rem
****************************************************************************
**********
rem Restart IB
rem
****************************************************************************
**********
net start "InterBase Guardian"
set IBStart0True=%ERRORLEVEL%
if NOT %IBStart0True% EQU 0 goto STARTFAIL
echo ****************************************************** >>
%BUDir%\ibbak.log
date /T >> %BUDir%\ibbak.log
time /T >> %BUDir%\ibbak.log
echo. IBStart0True=%IBStart0True% >> %BUDir%\ibbak.log
echo ****************************************************** >>
%BUDir%\ibbak.log

rem
****************************************************************************
**********
rem remove "save" directory then move the bin directory and show results to
log
rem
****************************************************************************
**********
rd /s/q %SVDir%
move %DBDir% %SVDir%
set Move0True=%ERRORLEVEL%
echo. ******************************************************* >>
%BUDir%\ibbak.log
date /T >> %BUDir%\ibbak.log
time /T >> %BUDir%\ibbak.log
echo. Move0True=%ERRORLEVEL% >>
%BUDir%\ibbak.log
echo. save directory should be below >>
%BUDir%\ibbak.log
dir %SVDir%\%DBNam%* >> %BUDir%\ibbak.log
echo. ******************************************************* >>
%BUDir%\ibbak.log
if NOT %Move0TRUE% EQU 0 goto MoveFAIL

rem
****************************************************************************
**********
rem An IB restore is called on BUDIR to DBDIR. A log entry is made.
rem
****************************************************************************
**********
set Rstr0True=1

if exist %DBDIR%\nul goto restore
md %DBDIR%
:RESTORE
Copy %CmdDir%udf.dll %DBDir%
%UTDir%\gbak.exe -R -C -user %DBUsr% -pas %DBPwd% -p 8192 -bu 1000
%BUDir%\%DBNam%.bak %DBDir%\%DBNam% 240000 %DBDir%\%DBNam%1 240000
%DBDir%\%DBNam%2 240000 %DBDir%\%DBNam%3 240000 %DBDir%\%DBNam%4 240000
set Rstr0True=%ERRORLEVEL%

rem set flag to error state; zero means success. [Do not move this comment
above the set flag command.]
rem Create log file with time, date, flag state, and a dir of ga.bak

echo. ------------------------------------------------------- >>
%BUDir%\ibbak.log
date /T >> %BUDir%\ibbak.log
time /T >> %BUDir%\ibbak.log
echo. Rstr0True=%Rstr0True% >> %BUDir%\ibbak.log
dir %BUDir%\%DBNam%.bak >> %BUDir%\ibbak.log
dir %DBDir%\%DBNam% >> %BUDir%\ibbak.log
echo. ------------------------------------------------------- >>
%BUDir%\ibbak.log

if NOT %Rstr0True% EQU 0 goto RstrFAIL
goto CycleIBService

:BACKFAIL
echo. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! >>
%BUDir%\ibbak.log
date /T >> %BUDir%\ibbak.log
time /T >> %BUDir%\ibbak.log
echo. The IB Backup Command Failed!!! >> %BUDir%\ibbak.log
echo. No Backup of database took Place! No Files Changed! >>
%BUDir%\ibbak.log
echo. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! >>
%BUDir%\ibbak.log

rem
****************************************************************************
**********
rem Notify the DBServerName via net messages that the process failed.
rem
****************************************************************************
**********
net send %DBServerName% "Call Bell & Howell technical software support!
Database Backup Process Failed!"
goto LEAVE

:MoveFAIL
echo. ???????????????????????????????????????????????????????? >>
%BUDir%\ibbak.log
date /T >> %BUDir%\ibbak.log
time /T >> %BUDir%\ibbak.log
echo. The Database Move Failed!!! >> %BUDir%\ibbak.log
echo. ???????????????????????????????????????????????????????? >>
%BUDir%\ibbak.log

rem
****************************************************************************
**********
rem put as entry into the log
rem
****************************************************************************
**********
echo. ******************************************************* >>
%BUDir%\ibbak.log
date /T >> %BUDir%\ibbak.log
time /T >> %BUDir%\ibbak.log
dir %DBDir%\%DBNam%* >> %BUDir%\ibbak.log
echo. ******************************************************* >>
%BUDir%\ibbak.log

rem
****************************************************************************
**********
rem Notify the DBServerName via net messages that the process failed.
rem
****************************************************************************
**********
net send %DBServerName% "Call Bell & Howell technical software support!
Database Move Process Failed!"
goto CycleIBService

:RstrFAIL
echo. ???????????????????????????????????????????????????????? >>
%BUDir%\ibbak.log
date /T >> %BUDir%\ibbak.log
time /T >> %BUDir%\ibbak.log
echo. The IB Restore Command Failed!!! >> %BUDir%\ibbak.log
echo. ???????????????????????????????????????????????????????? >>
%BUDir%\ibbak.log

rem
****************************************************************************
**********
rem remove "BIN" directory then move the "save" directory and show results
to log
rem
****************************************************************************
**********
rd /s/q %DBDir%
move %SVDir% %DBDir%
echo. ******************************************************* >>
%BUDir%\ibbak.log
date /T >> %BUDir%\ibbak.log
time /T >> %BUDir%\ibbak.log
dir %DBDir%\%DBNam%* >> %BUDir%\ibbak.log
echo. ******************************************************* >>
%BUDir%\ibbak.log

rem
****************************************************************************
**********
rem Notify the DBServerName via net messages that the process failed.
rem
****************************************************************************
**********
net send %DBServerName% "Call Bell & Howell technical software support!
Database Restore Process Failed!"
goto CycleIBService

:STARTFAIL
echo. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% >>
%BUDir%\ibbak.log
date /T >> %BUDir%\ibbak.log
time /T >> %BUDir%\ibbak.log
echo. The IB Restart Command Failed!!! >> %BUDir%\ibbak.log
echo. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% >>
%BUDir%\ibbak.log

rem
****************************************************************************
**********
rem Notify the DBServerName via net messages that the process failed.
rem
****************************************************************************
**********
net send %DBServerName% "Call Bell & Howell technical software support!
Interbase Guardian Startup Failed!"
goto leave

:CycleIBService
rem
****************************************************************************
**********
rem Stop IB
rem
****************************************************************************
**********
net stop "InterBase Guardian"
net stop "InterBase Server"

rem
****************************************************************************
**********
rem restore services file so that ib will talk again.
rem
****************************************************************************
**********
copy %CmdDir%BHSOFTWARE\SYSFILES\SERVICES.ORG
c:\winnt\system32\drivers\etc\Services

rem
****************************************************************************
**********
rem Restart IB
rem
****************************************************************************
**********
net start "InterBase Guardian"
set IBStart0True=%ERRORLEVEL%
if NOT %IBStart0True% EQU 0 goto STARTFAIL
echo ****************************************************** >>
%BUDir%\ibbak.log
date /T >> %BUDir%\ibbak.log
time /T >> %BUDir%\ibbak.log
echo. IBStart0True=%IBStart0True% >> %BUDir%\ibbak.log
echo ****************************************************** >>
%BUDir%\ibbak.log
if NOT %Rstr0True% EQU 0 goto leave
echo. >>
%BUDir%\ibbak.log
echo. ******************************************************* >>
%BUDir%\ibbak.log
date /T >> %BUDir%\ibbak.log
time /T >> %BUDir%\ibbak.log
echo. The IB Backup and Restore Commands were successful. >>
%BUDir%\ibbak.log
echo. ******************************************************* >>
%BUDir%\ibbak.log
:LEAVE
net send %DBServerName% "Database Backup/Restore Complete!"
@exit

((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((((

@Echo Off
rem
****************************************************************************
**********
rem Backup the database with the normal backup utility
rem
****************************************************************************
**********

copy %BUDir%\%DBNam%-2.Bak %BUDir%\%DBNam%-3.Bak
copy %BUDir%\%DBNam%-1.Bak %BUDir%\%DBNam%-2.Bak
copy %BUDir%\%DBNam%.Bak %BUDir%\%DBNam%-1.Bak

%UTDir%\gbak -g -b -user %DBUsr% -pas %DBPwd% %DBDir%\%DBNam%
%BUDir%\%DBNam%.Bak
set Backup0True=%ERRORLEVEL%

rem set flag to true if backup unsuccessful.
rem ****Do not have any line between the gbak and the set command. the
errorlevel will be reset.
rem Create log file with time, date, flag state, and a dir of ga.bak

echo. ------------------------------------------------------- >>
%BUDir%\ibbak.log
date /T >> %BUDir%\ibbak.log
time /T >> %BUDir%\ibbak.log
echo. Backup0True=%Backup0True% >> %BUDir%\ibbak.log
dir %BUDir%\%DBNam%.bak >> %BUDir%\ibbak.log
echo. ------------------------------------------------------- >>
%BUDir%\ibbak.log

((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((((


Best regards,
Fred Wilson
SE, Bell & Howell
fred.wilson@... <mailto:fred.wilson@...>




-----Original Message-----
From: Bob Murdoch [mailto:ram5@...]
Sent: Tuesday, January 29, 2002 11:57 AM
To: ib-support@yahoogroups.com
Subject: RE: [ib-support] Re: maintenance strategie


At 1/28/2002 05:01 PM, Fred Wilson wrote:
>We have an "automated" backup and restore for our sites. Here's what we do
>(Server = NT4.0 or W2000), via .cmd files and the windows scehduler (AT
>command):
>- make sure there are no connections to the database by stopping IB, copy a
>service file that has no gds entry (to stop anyone from logging into IB
>until we're finished), and restart IB
>- Backup the database using gbak to a backup directory and check for errors
>- If errors, log the event to a log file, stop IB, copy the old services
>file back in place, restart IB and quit
>- If no errors, stop IB, then, using the command "MOVE", move the active
>database directory to a "save" directory.
>- Start IB
>- Restore the backup to the active database directory
>- If errors, stop IB, and delete the "restored" database files and "MOVE"
>the save directory back to the active directory, copy the old services file
>back to the original,restart IB, log the event, and quit
>- If no errors, log the event, stop IB, copy the original services file
back
>into place, restart IB and we're finished

Fred,

Would you be willing to share a sample script? I have my own, but they
are not nearly as involved as yours. In particular, I'm wondering how you
handle stopping the IB service (assuming NET STOP) if there are users
connected, and how you are checking for errors from gbak.


tia,

Bob M..



Yahoo! Groups Sponsor
[]



_____


<http://us.adserver.yahoo.com/l?M=153641.1824646.3335993.1261774/D=egroupmai
l/S=1705007709:HM/A=919357/rand=208179238>

To unsubscribe from this group, send an email to:
ib-support-unsubscribe@egroups.com



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
<http://docs.yahoo.com/info/terms/> .