Create Backup of Back-end .mdb

123dstreet

Registered User.
Local time
Yesterday, 16:47
Joined
Apr 14, 2010
Messages
122
Hi All!

I have been searching but cannot find direct answer to my problem. I currently have a macro to backup my backend file on an hourly basis, but it will only do it when the user is on at the turn of each hour. How would I change this to perform a backup everytime the user EXITS the front-end file? I cannot seem to figure it out, Thanks in advance!!
 
Hi All!

I have been searching but cannot find direct answer to my problem. I currently have a macro to backup my backend file on an hourly basis, but it will only do it when the user is on at the turn of each hour. How would I change this to perform a backup everytime the user EXITS the front-end file? I cannot seem to figure it out, Thanks in advance!!

Do they exit via a command button, or by the application window close?
 
There is an Exit button on the Main Switchboard, but the user's frequently forget about it and use the Exit on the application. But, if there is a way to create this Macro by using the Exit Button on the Switchboard, I will make that work.. Thanks
 
There is an Exit button on the Main Switchboard, but the user's frequently forget about it and use the Exit on the application. But, if there is a way to create this Macro by using the Exit Button on the Switchboard, I will make that work.. Thanks

Try this sample out for some ideas. Extract to C:\
 

Attachments

Thanks for the prompt response! I just have a couple questions regarding this code:

Code:
Private Sub btn_Quit_Click()
On Error GoTo Err_btn_Quit_Click
    Dim FSO
   [COLOR=red] Set FSO = CreateObject("scripting.filesystemobject")
[/COLOR]    Dim NewName
    NewName = Replace(Now, "/", "")
    NewName = Replace(NewName, " ", "")
    NewName = Replace(NewName, ":", "")
    NewName = NewName & ".mdb"
    NewName = "C:\1_YourDBLoc\backups\YourDB" & NewName
    DoCmd.Save
    FSO.Copyfile "C:\1_YourDBLoc\YourDB.mdb", NewName
    DoCmd.Quit
Exit_btn_Quit_Click:
    Exit Sub
Err_btn_Quit_Click:
    MsgBox Err.Description
    Resume Exit_btn_Quit_Click
    
End Sub

The code in RED; is that going to be just like that? or do I need to re-do that to be specifically for my database? THANKS...
 
Code:
Private Sub btn_Quit_Click()
On Error GoTo Err_btn_Quit_Click
    Dim FSO
   [COLOR=red] [COLOR=Black]Set FSO = CreateObject("scripting.filesystemobject")[/COLOR]
[/COLOR]    Dim NewName
    NewName = Replace(Now, "/", "")
    NewName = Replace(NewName, " ", "")
    NewName = Replace(NewName, ":", "")
    NewName = NewName & ".mdb"
    NewName = "[COLOR=Magenta]C:\1_YourDBLoc\backups\YourDB[/COLOR]" & NewName
    DoCmd.Save
    FSO.Copyfile "[COLOR=Magenta]C:\1_YourDBLoc\YourDB.mdb[/COLOR]", NewName
    DoCmd.Quit
Exit_btn_Quit_Click:
    Exit Sub
Err_btn_Quit_Click:
    MsgBox Err.Description
    Resume Exit_btn_Quit_Click
    
End Sub

Just need to update the code in pink to match your backend location (and create the backups folder.
 
123dstreet -- I have been looking for a macro to back up my back end. Are you willing to share?

Thanks!!
 
Hey swarm, that post is from 2011. That user might not be watching that thread anymore . . .
 
Hi MarkK,

I just use a simple macro to backup the backend file to my local machine, although I'm sure you can back it up wherever you like.

I use a timed backup, so the top of every hour this macro runs:

For the condition:
Time()>=TimeValue("07:00:00") And Time()<TimeValue("07:01:00")

Action:
RunApp

Arguments:
xcopy R:\"Inventory Database"\backendfile.mdb c:\backup\7am\/I/Y
 
Button Backup for access 2010

Private Sub Button_Backup_Click() Dim str As String Dim buf As String Dim MD_Date As Variant Dim fs As Object Dim source As String Const conPATH_FILE_ACCESS_ERROR = 75 On Error GoTo Backup_Button_Backup 'buf = Back Up Folder 'buf is created if it does not exist 'CurrentProject.Path = the path that the FE is located buf = CurrentProject.Path & "\Backups\" MkDir buf Resume Backup_Button_Backup Backup_Button_Backup: 'Use yyyy-mm-dd hh-mm-ss as folder name. Change as needed. MD_Date = Format(Date, "yyyy-mm-dd ") & Format(Time, "hh-mm-ss") str = CurrentProject.Path & "\Backups\" & MD_Date 'Source = where the data is stored source = CurrentProject.Path & "\Data\" MkDir str Set fs = CreateObject("Scripting.FileSystemObject") 'Change the file extension as needed fs.CopyFile source & "*.accdb", str Set fs = Nothing MsgBox "Data backup at " & vbCrLf & MD_Date & vbCrLf & "successfully!", _ vbInformation, "Backup Successful" Exit_Button_Backup: Exit Sub Err_Button_Backup: If err.Number = conPATH_FILE_ACCESS_ERROR Then MsgBox "The following Path, " & str & ", already exists or there was an Error " & _ "accessing it!", vbExclamation, "Path/File Access Error" Else MsgBox err.Description, vbExclamation, "Error Creating " & str End If Resume Exit_Button_Backup End Sub

Credit to the owner of the code
Guys I have a problem in this code.

Run time error 76
Path not found

please, if you can share some of your ideas regarding this error.
Thanks
 
another alternative would be to use 3rd party software like goodsync, therefore you dont need to worry wether your BE has been backed up or not.
 

Users who are viewing this thread

Back
Top Bottom