Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatic Backup of Access2k database 1

Status
Not open for further replies.

Pelle55

Technical User
May 5, 2002
13
0
0
SE
Hi!
Does anyone know how two make a backup of an Access2k db?
I want an automatic backup scheduled for example at 22.00 every friday night.
 
Ok, maybe that would work. But how do I start the automatic backup? I´ve found a vbscript that makes a copy of the db and name it after the day and time the copy is made. But I do not know how to run it automatic.
The script looks like this:

Script To Create Backup Copy of Access database
' *****************************************************
' Script To Create Backup Copy of RC3.mdb *
' *
' Danny J. Lesandrini August 28, 2000 *
' dan@dea.com or datafast@home.com *
' Dean Evans & Associates, Inc *
' *
' *
' *
' This script was created to simplify the process *
' of backing up a development copy of an MS Access *
' database. *
' *
' The same process can be used in reverse to copy *
' a development master file to the user's desktop *
' for editing. The file is renamed with a prefix *
' created from the current Date and Time, thus *
' making it unique (assuming you don't execute the *
' script more frequently than once per minute). *
' *
' *****************************************************

Dim strRootPath
Dim strFileName

Dim objScript

Dim strPrefix
Dim strMonth
Dim strDay
Dim strYear
Dim strHour
Dim strMinuite

Dim strSource
Dim strTarget
Dim strMsg


' **** The following 2 lines of code are the only variables that need be edited
' **** Enter your path and the name of the file you wish to backup.
' ****
' **** NOTE: It is assumed that a folder named "Archive" exists under the above-
' **** named Root Path. If that folder does not exist, then create it later.
'
strRootPath = "C:\Test\"
strFileName = "RC3.mdb"

' **** To provide a unique prefix for the backup file, the current date and time
' **** is parsed and concatonated into a string variable
'
strMonth = DatePart("m",Date())
If Len(strMonth) = 1 Then strMonth = "0" & strMonth

strDay = DatePart("d",Date())
If Len(strDay) = 1 Then strDay = "0" & strDay

strYear = Right(DatePart("yyyy",Date()),2)

strHour= DatePart("h",Now())
If Len(strHour) = 1 Then strHour = "0" & strHour

strMinuite = DatePart("n",Now())
If Len(strMinuite) = 1 Then strMinuite = "0" & strMinuite

strPrefix = strMonth & strDay & strYear & "-" & strHour & strMinuite & "_"

' **** Now that we know the Root Path, File Name and new Prefix, the Source and Target
' **** paths can be created.
'

strSource= strRootPath & strFileName
strTarget = strRootPath & "Archive\" & strPrefix & strFileName

' **** Create the Scripting Object and copy the file
' **** (First, we verify that the Archive Folder exists and, if
' **** absent, it is created.)
'
Set objScript= CreateObject("Scripting.FileSystemObject")

If Not objScript.FolderExists(strRootPath & "Archive\") Then
objScript.CreateFolder(strRootPath & "Archive\")
End If

objScript.CopyFile strSource, strTarget

' **** Clean up
'
Set objScript= Nothing

' **** Inform User that Operation is Completed
'
strMsg = "The following file:" & vbCrLf & Space(5) & strPrefix & strFileName & vbCrLf & vbCrLf & "has been created in the Archive folder."
MsgBox strMsg,,"Finished"
 
HI!
I just wrote it, it works incredible nice!
Thanks a lot, just wonder, maybe I can use some parts of the vbscript to name the backup file after the day it was taken. Any solution in Dos for that?
 
i was just playing with your code... that is exacly what i've been looking for for about a month... i made some modifications to make it fit my needs... but here's a thought for you... use this code in the on close of a form that stays open for all the users... then when ever a user closes the database, it'll run the code... and since it includes the time and date, you'll have multiple copies for each day that it's used... and if it's not used, you don't need to make a backup:)
(like a weekend or some thing:))

just an idea...

--Junior JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
Thanks that could be a good idea. But I'll get to many backups I guess....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top