backing up a database while in use

  • Thread starter Thread starter John Milbury-Steen
  • Start date Start date
J

John Milbury-Steen

Hi Access gurus,
I have a MS Access 2002 Database split into front and back ends, both of
which are on the server. So far, I have not tried to back up the back end
while the database is in use. Instead, once a day, I kick everybody off,
back it up, and then make it available again. This is inconvenient for
everybody! Is there any risk in copying the back end of a database while it
is in use? (That is, while it has a Lock File associated with it?) Will
Windows COPY handle the semaphores and all that stuff correctly to make it
safe?
 
This works ... so long as it's not opened exclusively ...


Private Sub cmdBackup_Click()
On Error Resume Next

' This solution works for Access 2003
'CommandBars("Menu Bar").Controls("File").Controls("Back Up
Database...").accDoDefaultAction

Dim sSource As String
Dim sTarget As String
Dim sMsg As String
Dim frm As Form
Dim objFSO As FileSystemObject
Dim objFile As File
Dim sTimeTag As String

DoCmd.Hourglass True
sTimeTag = Format(Now(), "_yy-mm-dd_hh-nn")
Set objFSO = New FileSystemObject


sSource = CurrentDb.Name
sTarget = "R:\Backups\Regal_Database" & sTimeTag & ".mdb"
Set objFile = objFSO.GetFile(sSource)
objFile.Copy sTarget
Set objFile = Nothing

sSource = "R:\CompanyContact.mdb"
sTarget = "R:\Backups\CompanyContact" & sTimeTag & ".mdb"
Set objFile = objFSO.GetFile(sSource)
objFile.Copy sTarget
Set objFile = Nothing


Set objFSO = Nothing
DoCmd.Hourglass False

If Err.Number = 0 Then
sMsg = "Backup file created at ..." & vbCrLf & sTarget
MsgBox sMsg, vbInformation, "Finished"
Call ResetMessageVarables
Else
sMsg = Err.Description
MsgBox sMsg, vbCritical, "Error"
End If

End Sub

--
Danny J. Lesandrini
(e-mail address removed)
www.amazecreations.com/datafast


...
 
Is there any risk in copying the back end of a database while it
is in use?

Yes. Critical and irreversible corruption of the systems tables and
your data, for starters, if anyone is updating anything in the table
as it's being backed up.

You're doing it right. If you want "hot backups" you'll need to use a
client/server system such as SQL/Server, Oracle or MySQL.

John W. Vinson[MVP]
 
Back
Top