Scheduling backups on Windows NT 4.0 and Windows 2000 Server/Workstation

On Time Support, Inc.      Application Note


Scheduling backups on Windows NT 4.0 and Windows 2000 Server/Workstation
Also updated for MET/CAL version 7

Starting with version 4.0 of MET/TRACK, the database management responsibilities have moved from the client to the database server. While using a database engine/server provides better management of your data, it also requires special considerations when it comes time to back up this data.

Watcom (now Sybase) had this consideration in mind when they distributed their database product. Included in the distribution disks is a small utility named DBBACKUP.EXE. This program is put into the same directory where the database engine resides (typically C:\WSQL40\NT or C:\SQLANY50\WIN32) when you install the Watcom Server component of MET/TRACK. When supplied with the proper command line arguments this program will make a duplicate of your database and log file into a drive/directory of your choice. By using the built-in scheduling services of Windows NT Server/Workstation 4.0, we can make the chore of backing up your database automatic.

For NT Users

The first step in setting your system to make automatic backups is to make sure that the scheduling services of Windows NT are running. To do this, at your server click on START | SETTINGS | CONTROL PANEL. The control panel will now be displayed. Double-click on the SERVICES icon, then scroll down the list of available services and double-click on the SCHEDULE service. A service edit window will be displayed. Set the STARTUP TYPE to AUTOMATIC, and make sure that the LOG ON AS section is set to SYSTEM ACCOUNT and ALLOW SERVICE TO INTERACT WITH DESKTOP is enabled. Click on START to start the service. After the service has started, click on OK. Click on CLOSE and exit the control panel.

For WIN2000 Users

The first step in setting your system to make automatic backups is to make sure that the scheduling services of Windows 2000 are running. To do this, at your server click on START | SETTINGS | CONTROL PANEL.  The control panel will now be displayed.  Next Click in the Administrative Tasks Icon.   Double-click on the SERVICES icon, then scroll down the list of available services and double-click on the TASK SCHEDULER service.  It should show a status of running.  You can double click on the service name and the properties will be displayed.  If the service is not running, then follow the next step to start the service, otherwise go to next section to set up the backup.  Set the STARTUP TYPE to AUTOMATIC, and make sure that the LOG ON AS section is set to SYSTEM ACCOUNT and ALLOW SERVICE TO INTERACT WITH DESKTOP is enabled. Click on START to start the service. After the service has started, click on OK. Click on CLOSE and exit the control panel.

Setting up the Backup

The next step is to enter an event into the AT scheduling service. Go to the DOS prompt.  For WIN2000 users, click START | RUN.  Type in CMD.EXE and press enter.  The command window will appear.  If you have Windows 2000, do not use the task scheduler in the control panel.  It does not seem to work when the user is logged out.  You must be in the command window.  This window is sometimes seldom used to execute commands.  At the prompt enter the following command:

AT

This will either display a list of scheduled activities that the server is currently using, or there may not be any events scheduled. This command will be used later to verify proper entry of the backup command.

Now we can enter a new event. Enter the following command, modifying it to match your system as follows:

Watcom Database Engine (All versions of MET/TRACK 4): AT 01:00 /interactive /every:m,t,w,th,f,s,su c:\wsql40\nt\dbbackup.exe -x -y -c uid=mt;pwd=mt d:\backup

Replace the parameter "mt" immediately after "pwd=" to reflect your correct mt user password. Also, "d:\backup" may be replaced with the correct drive and path of your choice.

Sybase Anywhere Engine (MET/TRACK 5.x and 6.x): AT 01:00 /interactive /every:m,t,w,th,f,s,su c:\sqlany50\win32\dbbackup.exe -x -y -cuid=mt;pwd=mt;dbf=database-name d:\backup

Sybase Anywhere Engine (MET/TRACK 7.x and higher): AT 01:00 /interactive /every:m,t,w,th,f,s,su "c:\sybase8\SQL Anywhere 8\win32\dbbackup.exe" -x -y -cuid=mt;pwd=mt;dsn="Calibration Data" d:\backup

NOTE: On MET/CAL version 7, you will need double quotes around the path for the dbbackup program, like the example above.

Replace the parameter "mt" immediately after "pwd=" to reflect your correct mt user password. Replace database-odbc name with the odbc database name you have set up for MET/TRACK after "dsn=".  This is the name that shows in the toolbar when you run programs like manual entry.  Also, "d:\backup" may be replaced with the correct drive and path of your choice, but it has to be on the local computer.

After you add this command, you should see a message like: Added event with job id = xxx. This means that the backup event was accepted. Here are explanations for sections of the command line to modify:

01:00 - time of the day (in 24hr format) to perform the event

/interactive - allow display to show on the desktop (recommended)

/every:m,t,w,th,f,s,su - days of the week to perform the event (every day in this case)

c:\wsql40\nt\dbbackup.exe - the Watcom/Sybase utility that does the backup. Change the drive/path to reflect your setup on the server.
Sybase Anywhere 5.5: C:\sqlany50\win32\dbbackup.exe.
Sybase Anywhere 8 "c:\sybase8\SQL Anywhere 8\win32\dbbackup.exe"

-x truncate the transaction log.

-y allow overwrites and answer yes to questions.

-c uid=mt;pwd=mt - log on account (uid) is "mt" (system administrator), and the password (pwd) is "mt". Change this part to reflect your "MT" password. The dbbackup utility must have dba authority (mt user) to work correctly.  The -c means that commands are to follow.

d:\backup - drive and path for the backup files to go (mtrack.db, mtrack.log)

If you need to make changes to this statement later, such as changing the "MT" password, you must delete this event and add a new one with the correct information. Delete the old event as follows:

AT

This will show you the event and it's JOB ID.

at ^ xx ^ /del - replace xx with the JOB ID.

This will delete the old event. Add the new event like you did before, replacing old information in the command line with any changes you need to make.

Scheduling the Time

Some labs will set up a separate event for each day of the week and have the data copy to a different directory.  For example, you might set up MONDAY-FRIDAY target directories.  This would save backups to a different place for each day of the week instead of overwriting the old data.  You could even write all the weekday directories to a CD at the beginning of the week. This does use a lot of hard drive space.  Some labs need this and some do not.  You need to think about your needs.

You could also set the backup time to occur at lunch time instead of night or have more than one backup performed daily.  The Sybase system does not require everyone to log off while the backup occurs and the procedure is invisible to the users.

Important Notes, Please Read:

1. This program (DBBACKUP.EXE) creates a "mirror image" of your database and puts it into the drive/directory of your choice. This mirror image can be copied to your METDATA directory on the server to "start over" if your database becomes corrupted. Just move or delete the corrupted database files in your METDATA directory and copy the "mirror image" files into the METDATA directory. You database will be back to the point it was at the time of the backup.

2. The data/time on the mtrack.db file may be confusing. It might be a date sometime in 1969. Don't panic. This happens on some NT systems, and it doesn't cause problems.  If you want to see the actual date and time of the backup, look at the mtrack.log file in your backup directory.  You cannot depend on the date and time displayed for the mtrack.db file.  Sybase allocates drive space only when the system needs more space, and that is when the date and time stamps are updated.

3. The purpose of this exercise is to put copies of your database in a different location so that another backup program can put them onto another media (tape, removable drive, etc.). This backup process can happen several times a day if you like, by adding more than one event. After DBBACKUP.EXE finishes, other backup software can back up these files for you. Backup software other than what has been supplied by Watcom/Sybase cannot back up files in the METDATA directory since they are locked by the database engine. The steps outlined in this applications note are the only way to properly back up your database.

4. Be sure to verify that the backup files are really being backed up on the tape system. We have seen some tape systems which did not work properly. It is a good idea to verify database backups to make ensure system integrity.  If you IT Department is performing the backup, ask them to restore the backup and test the system.

5. Really important - If you change your MT password in the MET/TRACK admin program, the database backup will stop working until the password is updated in the AT scheduler.  Sometimes these passwords are changed without considering the backup system.  It is a good practice to verify the backup system on a weekly or monthly basis.

Important: Back up your METCAL Directory

One last but important item, make sure the METCAL directory on your server is being backed up.  This directory and sub-directories contain procedures, reports, and several other important system files.  If your IT department is performing the backup, ask them to practice a restoration for you.  Its better to find out now, than to find out later that the procedure did not work.

If you are managing the server in the lab and use media like ZIP or JAZZ, try using the xcopy command to backup you data.  It can be set in the AT scheduler also.  Here is an example, but remember to check it out for yourself and make sure it really works:

AT 20:00 /interactive /every:m,t,w,th,f,s,su c:\winnt\system32\xcopy /E /V /I D:\METCAL\*.* F:\METCAL

This command will backup the METCAL directory and sub-directories at 10PM and they will be copied to the METCAL directory on the F: drive.  This might be a ZIP or JAZZ drive.  Remember, as far as NT is concerned, for this to work when the console is logged out, the destination must be a local drive.

Feel free to let us know if this procedure helps you, or if you have suggestions.
 

             ON TIME SUPPORT, INC
             25132 Oakhurst, Ste. 185
             Spring, Tx 77381
             email: inquiries@ontimesupport.com

             Tel: 281.296.6066  Fax: 281.465.9478