'***************************************************** ' File: backupDBs.vbs ' Note=>WSH requires the .vbs file extension ' ' Use: This script backs up the MasterWeb.mdb MS Access ' database every day at the time specified using ' the Scheduler. The backup file name includes ' the result of the weekday() function resulting ' a backup file for each day of the week. ' ' Author: Doug LaMar ' dlamar@lamarsoft.com ' ' Set up timed execution of this script using ' Windows NT/98 Scheduler '****************************************************** Option Explicit Dim IsLocked, txtStreamOut, MdbUpdateLog, bakFile, origMdbFile Dim origLdbFile, fso, oFile, WshShell ' Change these directory & filenames as required for your database & system MdbUpdateLog = "D:\InetPub\wwwroot\Database\Backup\MdbUpdateLog.txt" bakFile = "D:\InetPub\wwwroot\Database\Backup\MasterWeb" & CStr(Weekday(Now())) & ".mdb" origMdbFile = "D:\InetPub\wwwroot\Database\MasterWeb.mdb" origLdbFile = Left(origMdbFile,(Length(origMdbFile)-3)) & "ldb" Set fso = WScript.CreateObject("Scripting.FileSystemObject") Set WshShell = WScript.CreateObject("WScript.Shell") Set txtStreamOut = fso.OpenTextFile(MdbUpdateLog, 8, True) '************************************************************ ' Backup the MasterWeb.mdb database file on the Web server '************************************************************ IsLocked = True While IsLocked If (fso.FileExists(origMdbFile)) Then If (fso.FileExists(origLdbFile)) Then ' Database locked by Access IsLocked = True WScript.Sleep 60000 ' Wait 1 minute Else ' Database free IsLocked = False End If Else ' File doesn't exist txtStreamOut.WriteLine origMdbFile & " does not exist " & CStr(now()) WScript.Quit End If Wend Set oFile = fso.GetFile(origMdbFile) ' Get File Object oFile.Copy bakfile, True ' Overwrite existing target txtStreamOut.WriteLine origMdbFile & " backed up - " & CStr(now()) '************************************************************ ' Clean up '************************************************************ Set fso = Nothing Set WshShell = Nothing Set txtStreamOut = Nothing