//////////////////////////////////////////////////////////////////////// // // This is a sample .TSK file which can be modified as appropriate // towards insuring the integrity of a backup by issuing warnings // to active users and then clearing their connections before // shutting down the database and initiating the backup. // //////////////////////////////////////////////////////////////////////// // Send a broadcast alerting any logged in users that the System // will be shutdown in 5 minutes so they should log out NOW! SEND "System will be off-line in 5 minutes for backup!" SEND "Please logout immediately!" // Pause the task for 5 minutes (300 seconds) WAIT 300 // Disable logins so no one can log back in until we are ready for them DISABLE LOGIN // Clear argument %0 for use as a connection counter DEFINE %0 0001 // Check all the possible connections (up to the Peak Connections // which are logged in) for an active user WHILE %0<=%CONNS_PEAK% // Check the connection status for INACTIVE or NOT-LOGGED-IN returns IF NOT "%CONN_NAME_%0%"=="INACTIVE" AND NOT "%CONN_NAME_%0%"=="NOT-LOGGED-IN" // Must be an active user since check for INACTIVE and NLI failed // First we will SEND the connection a warning... SEND "Your connection will be cleared in 30 seconds. Logout!" to %0 // Now we will wait 35 seconds (giving a fudge factor)... WAIT 35 // And then we WILL clear the connection (as promised)! CLEAR STATION %0 ENDIF // Increment our connection counter DEFINE %0 %0+=1 // Loop back to the WHILE conditional check LOOP // All connections have now been cleared and logins are disable // Time to proceed with the database shutdown and backup processes // This line simulates the loading of an NLM which is used to shutdown // and/or re-index an active database engine LOAD SQLADMIN SHUTDOWN // Check if SQLADMIN is loaded every 5 secs (unloads when finished) WHILE LOADED SQLADMIN WAIT 5 LOOP // SQL is shutdown so it is safe to unload the Database engine UNLOAD DBENGINE // Don't Backup if Database engine unload failed IF NOT LOADED DBENGINE // Now it is safe to load the BACKUP software (don't need it before) LOAD BACKUP // The following lines will: Change the active Server Console screen // to the Backup NLM screen; Simulate the key in of the F1 function // key (which starts the backup process); Periodically (every 15 // seconds) scan the Backup NLM screen for the word 'Finished'; Check // for any errors; And, then unload the Backup NLM if either appear. CHANGE_SCREEN "Backup Screen" KEYIN F1 WHILE NOT SCAN_SCREEN "Finished" IF SCAN_SCREEN "Error" ECHO Backup process failed! Check the error log. BREAK ENDIF WAIT 15 LOOP UNLOAD BACKUP ELSE ECHO Backup process failed! Unable to unload Database engine. ENDIF // Ensure that the DBENGINE NLM is loaded (CALL the task to load it, if not) IF NOT LOADED DBENGINE THEN CALL LOAD_DB.TSK // Re-Enable logins ENABLE LOGIN