Solved

Database Replication Act As Backup?

Posted on 2004-08-20
10
260 Views
Last Modified: 2012-05-05
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.
0
Comment
Question by:Malinthas
  • 4
  • 2
  • 2
  • +1
10 Comments
 
LVL 4

Expert Comment

by:naivad
ID: 11851959
does repairing the database not work?
0
 
LVL 36

Accepted Solution

by:
SidFishes earned 125 total points
ID: 11852016
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
 

Author Comment

by:Malinthas
ID: 11852022
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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 36

Expert Comment

by:SidFishes
ID: 11852033
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
 

Author Comment

by:Malinthas
ID: 11852096
I'm not too worried about replicating the corruption, since Access crashes as soon as the network error occurs.
0
 
LVL 4

Expert Comment

by:naivad
ID: 11852201
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
 
LVL 36

Expert Comment

by:SidFishes
ID: 11852202
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
 
LVL 36

Expert Comment

by:SidFishes
ID: 11852247
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
 
LVL 65

Expert Comment

by:Jim Horn
ID: 11852602
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
 
LVL 65

Expert Comment

by:Jim Horn
ID: 12166983
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

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question