Mirror a Database at several sites
This script mirrors APT's customer data base
files at two remote locations. It operates on weeknights. Note the manner in which this is
accomplished. The DAILY repeat command repeats the script every day. However, we
use a transfer and a conditional to limit the days to those we want.
The script simply fails the conditional on the weekends.
The basic flow is this:
1. Determine whether this is a day to operate.
2. Shut down the data base and zip up the files.
3. Transfer the zipped file to the remote locations.
4. Start the unzip routine at each remote site.
Each step is checked for failure using a
conditional.
:Comment:#
Ignore anything after a "#" character on a line
:RepeatTime:Daily
:MaxPerServer:1
:Archive:None
:Speed:+5 |
#
Repeat every 24 hours
# Run one transfer at a time to each site
# Do not archive either the source or target
# Operate each transfer with a window of 6
# messages |
:Serverlist:Remotes
Sterling
Brighton
:EndList:
# Check for the proper day. The
\mirror\days directory contains
# files for each day we wish to operate: MON, TUE, WED, etc.
# The %DW wild
card will generate a name for the file based on
# the day of the week.
If the file is copied, we keep running.
# Otherwise we quit.
:From:
o:\mirror\days\%dw
:To
: o:\mirror\days\temp.day
:IF:
DayCheck
CompletedOK
#Check
for the correct day to run
# Kill the temporary file for the next time.
:DeleteFiles:
o:\mirror\days\temp.day
# Shut down the data base server. If this
fails, we fail the script
:Run:
o:\aptdb\admin.exe,-disconnect,o:\aptdb,2
:IF:
DBClose
CompletedOK
#Disconnect
data base
# Zip the data base files.
:Run:
h:\util\pkzip o:\aptdb\db.zip o:\aptdb\db\cust.* > o:\aptdb\zip.log,,o:\aptdb,10
:IF:
DBZip CompletedOK
#Zip
the data base files
# Restart the data base server.
:Run:
o:\aptdb\admin.exe,-resume,o:\aptdb,2
:IF:
DBOpen
CompletedOK
#Reconnect
data base
# Declare the server list and perform the
transfers. Our global
# restart parameters provide for up to 10 restarts on a variety of
# errors. Note that a failure on one server does not affect the
# other
:From:
o:\aptdb\db.zip
:To
: {!Remotes}c:\db\db.zip
:IF:
ZipOut
CompletedOK
#Send
zip to remote sites
# Finally, we queue the unzip job at each site.
:QueueDistribution:{!Remotes}c:\bftp\dbunzip.dcf
:IF:
QUnzip
CompletedOK
#Queue job at each remote site
:End_If:
:End_If:
:End_If:
:End_If:
:End_If:
:End_If: |