Database Replication Act As Backup?

At work, we're using an Access 2002 database, split into a front & back end.  Occasionally, we'll get a network hiccup, resulting in "disk or network error".  Actually, we get them quite often.  Usually, we just close and restart the database, but occasionally the back end will be corrupted.  We can restore it from the previous night's tape backup, but then we lose the day's work and need to re-enter it all.

We were wondering if we could use database replication as a form of constant, incremental backup.  Could we set up our database back end to replicate, then just copy the replica if the functional back end gets corrupted?  That might result in a much smaller loss of data, right?  Just an idea.
MalinthasAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
SidFishesConnect With a Mentor Commented:
I used to use this procedure to make backup replicas every 30 minutes...worked great and if there was a corruption in the master, just copy the latest replica, convert it to design master and you're up and running in less than 10 minutes...


Public pubLastSync As Date
Public varExit As Boolean


  Sub SynchronizeDbs(strDBPath As String, strSyncTargetDb As String)
       Dim dbs As Database
          Repaint
         Me!Progress = "Syncing: " & strSyncTargetDb
           
       Set dbs = OpenDatabase(strDBPath)
       ' Synchronize replicas (bidirectional exchange).
       dbs.Synchronize strSyncTargetDb, dbRepImpExpChanges
       dbs.Close
  pubLastSync = Now()
   
   Me!LastSync = "LastSync: " & pubLastSync
Repaint
       
   End Sub

Private Sub Command8_Click()
varExit = False
End Sub

Private Sub SyncNow_Click()
 Me!NextSync = ""
Call SynchronizeDbs(strDBPath:="\\server\Master\My.mdb", strSyncTargetDb:="\\server\Replica\myReplica.mdb")
Me!Progress = " --- Waiting ---"
Dim PauseTime, Start, Finish, TotalTime

    PauseTime = 1800   ' Set duration.
    Me!NextSync = "NextSync: " & DateAdd("s", 1800, pubLastSync)
   
   Start = Timer   ' Set start time.
    Do While Timer < Start + PauseTime
        DoEvents    ' Yield to other processes.
         
    Loop
    Finish = Timer  ' Set end time.
    TotalTime = Finish - Start  ' Calculate total time.
   
 

SyncNow_Click
End Sub
0
 
naivadCommented:
does repairing the database not work?
0
 
MalinthasAuthor Commented:
Not generally.  When we attempt a repair, we get one of two errors; either the database is identified as an unknown format, or it locks us out, saying more than one user is attempting to access the same data at the same time.  At that point, we can't open the file at all, even to attempt another repair.  We also can't get at it to import the data into another database.
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
SidFishesCommented:
one caveat to this is to make SURE you stop the replication "agent" as soon as corruption is noticed...or it will try to replicate the corrupt data...and may hose your replicate as well...
0
 
MalinthasAuthor Commented:
I'm not too worried about replicating the corruption, since Access crashes as soon as the network error occurs.
0
 
naivadCommented:
I developed a solution for this..but it is not so simple.

I have a hidden form that is always open. This form has a timer event on it that is linked to another external database. That databases only purpose is to set a single record in a single table (kickUsers). If I set this value to true, then all of the users get a "5 minutes to close database countdown" if the user is away from the computer, Access will shut itself off.

New people trying to get into the database can't because the first thing the DB looks for is that kickUsers flag isn't set.

I can now modify/compact/repair/backup the database.

I now also have a scheduled task that automates this, captures a list of all the users that are logged into my database when it sets the kickusers flag, compacts and repairs the database, and resets the kickuser flag, then finally notifies all the users that were in the database when it corrupted that it is safe to use the database again.

Unfortunately I moved projects and I don't have access to that code at the moment...I could do it again, but don't have time to do it right this second.
0
 
SidFishesCommented:
well...you need to run this function from a standalone app...so it won't necessarily crash when your user app does..

also ...for reasons i never investigated...it stops running at midnite...so you need to restart it every morning (or find out what's up with the timer...)

it's not perfect...but it saved my butt more than once.
0
 
SidFishesCommented:
naivad...i did that as well for a while...and also tried scripting a file copy every 30 minutes but found that for us, replication was the simplest and easiest to deal with...however...we were using replication anyway...the simplest choice is the scripted and chron'd file copy...you don't need to boot users to copy an mdb like you need to with backup...
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Your situation does not appear to be a candidate for Database Replication, so I'd avoid it like the plague.

It is intended to accomodate remote users who edit data and synching that data back to a central database, and adds a LOT of overhead to each record, so your application will be slower over time.  

The following MSDN article describes how to 'wash' a database as a preferred method to recover it when repair/compact does not work:  http://support.microsoft.com/default.aspx?scid=kb;en-us;283849

Hope this helps.
-Jim
_________
Jim Horn
Small Business Software Consultant
http://www.jimhorn.biz 

0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Malinthas - Looks like you've received some solid advice from multiple experts.  Since this question appears to be getting old, please consider awarding points for the effort and closing it.  Thanks in advance.  -Jim
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.