This material on VSS is an archive from fall 1998. First I changed jobs so I no longer had an association with VSS. Then after a couple more years I changed careers completely so I'm no longer associated with high tech at all. I've left the VSS material on this site for use by others, even though I no longer remember exactly what it's about or even understand some of it.
This material was originally posted on a website whose address has changed. Its old address may have been any of www.shore.net/~ckollars/xxxxx or www3.shore.net/~ckollars/xxxxx or www.primushost.com/~ckollars/xxxxx or www3.primushost.com/~ckollars/xxxxx. Its current address is simply www.ckollars.org/xxxxx
This material reflects experience with VSS5. The user interfaces and the feature set in VSS6 were virtually identical, so almost all of this material continued to apply for several years. But I have no detailed knowledge of the user interfaces or feature set of the now current VSS2005 and so don't know which parts of this material still apply.
This script, which is used in production, is an implementation of automatic VSS maintenance.
This script is implemented with WinBatch. WinBatch is a third party tool that provides plenty of control structures, many built in functions including some utility functions not available in the base OS, keystroke stuffing, menu item invocation, and monitoring of window titles. It's thought this script could be easily ported to another language, even a simpler one that did not do keystroke stuffing, menu item invocation, or monitoring of window titles, in particular the new Command Shell in Windows NT 4 with the NT Resource Kit as described by the book Windows NT Shell Scripting.
;debug(@ON)
; Backup_vss.wbt
wwwnt32i=1
result=AddExtender("WWWNT32I.DLL")
if (result==@FALSE)
wwwnt32i=0
endif
vssshare="%param1%"
vssloc="%param2%"
auto="%param3%"
backup=1
eject=1
Ticks = 10
if auto==""
auto = 0
warn=0
shutdown=0
else
auto = 1
warn=1
shutdown=1
endif
;vssshare = "VSS_Test"
;vssloc = "d:\vss_test"
;Get and clean up the date
tdate = TimeDate()
gosub CLEAN_DATE
logfile = "c:\vss\tools\backup\logs\%vssshare%-%date%.log"
if (auto==@FALSE)
;Open Main Dialog
while @TRUE
gosub MAIN_DIALOG
; Did we select Cancel?
if ButtonPushed==9
BoxOpen("","Shutting Down")
Delay(1)
BoxShut()
exit
endif
if ButtonPushed==7
break
endif
endwhile;
endif
loghand = FileOpen(logfile,"WRITE")
tdate=TimeDate()
gosub CLEAN_DATE
FileWrite(loghand, "Starting Backup of %vssshare% on %tdate%")
FileWrite(loghand, "-----------------------------------------------------------------")
;Notify users database will be going down.
if warn
tdate=TimeDate()
gosub CLEAN_DATE
FileWrite(loghand, "%time% : Warn users that database is going down.")
;RunWait(Environment("COMSPEC"), "/c net send /USERS %vssshare% will be going down in 5 minutes!")
;Sleep for 5 minutes
tdate=TimeDate()
gosub CLEAN_DATE
FileWrite(loghand, "%time% : Sleeping for 5 minutes.")
Delay(300)
endif
;Stop VSS Share to down database
if shutdown
if wwwnt32i
tdate=TimeDate()
gosub CLEAN_DATE
FileWrite(loghand, "%time% : Removing %vssshare% to shut down database.")
result=wntShareDel("",vssshare,0)
if (result==@FALSE)
FileWrite(loghand, "%time% : Error removing %vssshare%, share not found.")
endif
else
FileWrite(loghand, "%time% : Unable to remove %vssshare%, NT Network extender not loaded.")
endif
endif
;Backup Database
if backup
tdate=TimeDate()
gosub CLEAN_DATE
FileWrite(loghand, "%time% : Starting Backup of %vssshare%.")
FileClose(loghand)
loghand=0
;RunWait("ntbackup", "backup %vssloc% /e /v /d %vssshare% on %date% /b /hc:on /l%logfile%")
;Turn off Hardware compression to see if it speeds up backup
Run("ntbackup", "backup %vssloc% /e /v /d %vssshare% on %date% /b /hc:on /l%logfile%")
gosub CheckWindows
endif
;Eject Tape
if eject
tdate=TimeDate()
gosub CLEAN_DATE
if !loghand then loghand = FileOpen(logfile,"APPEND")
FileWrite(loghand, "%time% : Ejecting Tape.")
RunWait("ntbackup", "eject")
endif
;Recreate VSS Share
if shutdown
if !loghand then loghand = FileOpen(logfile,"APPEND")
if wwwnt32i
tdate=TimeDate()
gosub CLEAN_DATE
FileWrite(loghand, "%time% : Recreating %vssshare% to open database.")
result=wntShareAdd("",vssloc,vssshare,0,-1)
if (result==@FALSE)
FileWrite(loghand, "%time% : Error creating %vssshare%.")
endif
else
FileWrite(loghand, "%time% : Unable to recreate %vssshare%, NT Network extender not loaded.")
endif
endif
if !loghand then loghand = FileOpen(logfile,"APPEND")
tdate=TimeDate()
FileWrite(loghand, "-----------------------------------------------------------------")
FileWrite(loghand, "Backup of %vssshare% on %tdate% complete")
FileClose(loghand)
exit
:CLEAN_DATE
date = tdate
time = strsub(date,14,strlen(date)-14)
date = strsub(date,5,strlen(date)-5)
date = strreplace(date,"/","-")
date = strtrim(date)
index = strscan(date," ",0,@FWDSCAN)
date = strsub(date,1,index-1)
if (strlen(date) < 8) then date = "0%date%"
return
:MAIN_DIALOG
VSSBackupFormat=`WWWDLGED,5.0`
VSSBackupCaption=`VSS Backup`
VSSBackupX=10000
VSSBackupY=10000
VSSBackupWidth=195
VSSBackupHeight=80
VSSBackupNumControls=10
VSSBackup01=`2,3,102,DEFAULT,STATICTEXT,DEFAULT,"VSS Share Name"`
VSSBackup02=`70,2,120,DEFAULT,EDITBOX,vssshare,""`
VSSBackup03=`2,17,102,DEFAULT,STATICTEXT,DEFAULT,"Physical Location"`
VSSBackup04=`70,16,120,DEFAULT,EDITBOX,vssloc,""`
VSSBackup05=`12,31,102,DEFAULT,CHECKBOX,warn,"Warn Users",1`
VSSBackup06=`12,45,102,DEFAULT,CHECKBOX,shutdown,"Stop/Start Database",1`
VSSBackup07=`120,31,102,DEFAULT,CHECKBOX,backup,"Backup Database",1`
VSSBackup08=`120,45,102,DEFAULT,CHECKBOX,eject,"Eject Tape",1`
VSSBackup09=`58,63,64,DEFAULT,PUSHBUTTON,DEFAULT,"&Ok",7`
VSSBackup10=`126,63,64,DEFAULT,PUSHBUTTON,DEFAULT,"&Cancel",9`
ButtonPushed=Dialog("VSSBackup")
return
:CheckWindows
while WinExist("Backup") == @TRUE
If WinExist("Insert Tape") == @TRUE
SendKeysTo("Insert Tape", "!n")
Delay(Ticks)
tdate=TimeDate()
gosub CLEAN_DATE
if !loghand then loghand = FileOpen(logfile,"APPEND")
FileWrite(loghand, "%time% : ERROR!! No TAPE in drive!")
FileClose(loghand)
loghand=0
break
Else
Delay(Ticks)
Endif
endwhile
return
|
Location: N42 40.86' W070 50.35'
(North America> USA> Massachusetts> Boston> North Shore> Ipswich) Time: UTC-5 (USA Eastern Time Zone) (UTC-4 summertime --"daylight savings time") Email comments to Chuck Kollars |
|
All content on this Personal Website
(including text, photographs, audio files, and any other original works),
unless otherwise noted,
are available to anyone for re-use
(reproduction, modification, derivation, distribution, etc.)
for any non-commercial
purpose under a
Creative Commons License.
|