Go to Start Page

Backup

Search On:
    
   

Automated Backup script

For this script to work, you need write permission in the folder where you copy the backup to. It is ofcourse also possible to make a local backup of the database. For this it would suffice to point your browser towards the URL of the wiki database.

For added security I myself put cookie protection in the backup.asp and in the page which calls it. So you need to login and set a session cookie to make a backup. For the information below I removed this added security, because it would go beyond the backup-issue.

Call the backup script

You can call the special backup.asp page with the following asp/html code. It has some build in check to see if you are not replacing a fresh backup, which would undo your backup activity. Just a failsafe. To directly make the backup, see backup.asp section below.

 <a href="BACKUP.ASP" onclick="return confirm('Replace backup edited on <%
 Dim objFSO
 Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
 Dim objFolder
 Set objFolder = objFSO.GetFolder("ABSOLUTE PATH OF BACKUP FOLDER")
 TotalSize=0
 TotalNr=0
 For each objItem in objFolder.Files
   If objItem.Name="DATABASE FILENAME" then response.write FormatDateTime((objItem.DateLastModified), vbShortDate)
 Next 
 Set objFolder = Nothing
 Set objFile = Nothing
 Set objFSO = Nothing
 %> with current database edited on <%
 Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
 Set objFolder = objFSO.GetFolder("ABSOLUTE PATH OF DATABASE FOLDER")
 TotalSize=0
 TotalNr=0
 For each objItem in objFolder.Files
  If objItem.Name="DATABASE FILENAME" then response.write FormatDateTime((objItem.DateLastModified), vbShortDate)
 Next 
 Set objFolder = Nothing
 Set objFile = Nothing
 Set objFSO = Nothing
 %>?');">Backup</a> wiki database (current backup dd.
 <%
 Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
 Set objFolder = objFSO.GetFolder("ABSOLUTE PATH OF BACKUP FOLDER\")
 TotalSize=0
 TotalNr=0
 For each objItem in objFolder.Files
   If objItem.Name="DATABASE BACKUP NAME" then response.write FormatDateTime((objItem.DateLastModified), vbShortDate)
 Next 
 Set objFolder = Nothing
 Set objFile = Nothing
 Set objFSO = Nothing
 %>).

The actual backup.asp is below


 <%
 dim StrFileSource, StrFileDestination
 StrFileSource="ABSOLUTE PATH OF DATABASE"
 StrFileDestination="ABSOLUTE PATH OF BACKUP"
 set fso = Server.CreateObject("Scripting.FileSystemObject")
 Set f2 = fso.GetFile(strFileSource)
 f2.Copy(strFileDestination)
 Set f2 = nothing
 Set fso = nothing
 %>

Feedback

Please give comments and suggestion for this page. I realise that the link part doesnt look too efficient, but it works fine. Its an altered script of something else I used to display directories. I didnt feel like finding out how to directly select a file to use its properties.

~ Daniel 06/06/2005

Thanks very much Daniel for that tip. I will look at it

~ Elrey Ronald