Jumat, 18 Desember 2015

Re:[MS_AccessPros] Re: Backup tools

 

Bill-
Thanks a lot. I will download them all.
Best Regards,
Kevin



发自我的小米手机
在 "wrmosca@comcast.net [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com>,2015年12月19日 上午1:05写道:

 

Kevin -I have used Karenware's Replicator for years to back up my databases every hour. It has never broken anything even while the databases were open. The URL is http://download.cnet.com/Karens-Replicator/3000-2242_4-50127.html


Be sure to look for all the other Karenware tools as the author has passed away and her site in no longer maintained.


Regards,

Bill Mosca, Founder - MS_Access_Professionals

http://www.thatlldoit.com

Microsoft Office Access MVP

https://mvp.microsoft.com/en-us/PublicProfile/35852?fullName=Bill%20%20Mosca

My nothing-to-do-with-Access blog

http://wrmosca.wordpress.com


 




---In MS_Access_Professionals@yahoogroups.com, <zhaoliqingoffice@163.com> wrote :

John-
Thanks a lot. As I know, once I open the ms access, there will be two files, one is .accdb, the other is .laccdb. Is that possible to backup accdb once every hour while the .laccdb is still opening? Thanks. Is there third part apps to  backup the backend?  You know there're many users, it's hard to close the entire backend for backup purposes. Thanks.
Best Regards,
Kevin


 
Date: 2015-12-17 18:04
Subject: Re: [MS_AccessPros] Backup tools
 

Kevin-


If you are using my relink code, then you can do this on exit to do a backup.  Note that this code must run in an unbound (no record source) form that has no combo box or list box controls.  Most of my applications have a "frmMain" that is an unbound "switchboard" form for the user to get to the various parts of the app.  The Exit code looks like this:

Public Sub cmdExit_Click()
Dim intErr As Integer, frm As Form, intI As Integer, strData As String, strDir As String
Dim lngOpen As Long, datBackup As Date
Dim strLowBkp As String, strBkp As String, intBkp As Integer
Dim db As DAO.Database, rst As DAO.Recordset

    If vbNo = MsgBox("Are you sure you want to exit?", vbYesNo + vbQuestion + vbDefaultButton2, _
        gstrAppTitle) Then
        Exit Sub
    End If
    
    ' Trap any errors
    On Error Resume Next
    ' Make sure all forms are closed
    For intI = (Forms.Count - 1) To 0 Step -1
        Set frm = Forms(intI)
        ' Don't close myself!
        If frm.Name <> "frmMain" Then
            ' Close the form
            DoCmd.Close acForm, frm.Name
            DoEvents
        End If
        ' Note any error that occured
        If Err <> 0 Then intErr = -1
    Next intI
    
    ' Log any error beyond here
    On Error GoTo frmMain_Error
    
    ' Skip backup check if there were errors
    If intErr = 0 Then
        Set db = DBEngine(0)(0)
        ' Open ztblVersion to see if we need to do a backup
        Set rst = db.OpenRecordset("ztblVersion", dbOpenDynaset)
        rst.MoveFirst
        lngOpen = rst!OpenCount
        datBackup = rst!LastBackup
        rst.Close
        Set rst = Nothing
        ' If the user has opened 10 times or last backup was more than 2 weeks ago...
        If (lngOpen Mod 10 = 0) Or ((Date - datBackup) > 14) Then
            ' Ask if they want to backup...
            If vbYes = MsgBox("Management highly recommends backing up your data to avoid " & _
                "any accidental data loss.  Would you like to backup now?", _
                vbYesNo + vbQuestion, gstrAppTitle) Then
                ' Get the name of the data file
                strData = Mid(db.TableDefs("ztblVersion").Connect, 11)
                ' Get the name of its folder
                strDir = Left(strData, InStrRev(strData, "\"))
                ' See if the "BackupData" folder exists
                If Len(Dir(strDir & "BackupData", vbDirectory)) = 0 Then
                    ' Nope, build it!
                    MkDir strDir & "BackupData"
                End If
                ' Now find any existing backups - keep only three
                strBkp = Dir(strDir & "BackupData\MembershipBkp*.mdb")  ' << Fix this name
                Do While Len(strBkp) > 0
                    intBkp = intBkp + 1
                    If (strBkp < strLowBkp) Or (Len(strLowBkp) = 0) Then strLowBkp = strBkp
                    strBkp = Dir
                Loop
                If intBkp > 2 Then
                    Kill strDir & "BackupData\" & strLowBkp
                End If
                ' Now, setup new backup name based on today's date
                '  **** FIX NAME OF FILE IN LINE BELOW ****
                strBkp = strDir & "BackupData\MembershipBkp" & Format(Date, "yymmdd") & ".mdb"
                ' Make sure the target file doesn't exist
                If Len(Dir(strBkp)) > 0 Then Kill strBkp
                ' Create the backup file using Compact
                DBEngine.CompactDatabase strData, strBkp
                ' Now update the backup date
                db.Execute "UPDATE ztblVersion SET LastBackup = #" & Date & "#", dbFailOnError
                MsgBox "Backup created successfully!", vbInformation, gstrAppTitle
            End If
            ' See if error log has 20 or more entries
            If db.TableDefs("ErrorLog").RecordCount > 20 Then
                ' Don't ask if they've said not to...
                If Not (DLookup("DontSendError", "ztblVersion")) Then
                    DoCmd.OpenForm "fdlgErrorSend", WindowMode:=acDialog
                Else
                    db.Execute "DELETE * FROM ErrorLog", dbFailOnError
                End If
            End If
        End If
        Set db = Nothing
    End If
       
    ' We're outta here!
frmMain_Exit:
    On Error GoTo 0
    DoCmd.Close acForm, Me.Name
    Application.Quit acSaveNone
    Exit Sub

frmMain_Error:
    ErrorLog "frmMain", Err, Error
    Resume frmMain_Exit
    
End Sub

The first thing the code does is close all forms except "frmMain" where this code is running.  If you're using my relink code, then you built a ztblVersion in the back end database.  Every 10 times the app is opened (count is kept in ztblVersion), it offers to create a backup on close, and it keeps up to three copies in a subfolder called BackupData.

John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
SQL Queries for Mere Mortals 
(Paris, France)



On Dec 17, 2015, at 1:16 AM, zhaoliqingoffice zhaoliqingoffice@163.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

Dear All,
Is there free backup tools out there for backing up backends. Thanks.
Best Regards,
Kevin

__._,_.___

Posted by: zhaoliqingoffice <zhaoliqingoffice@163.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (7)

.

__,_._,___

Tidak ada komentar:

Posting Komentar