Adding Backup to a Deployment Package (1 Viewer)

Russp42

Registered User.
Local time
Yesterday, 20:49
Joined
Nov 27, 2017
Messages
53
What is the easiest method of installing a backup option into a deployment package. Or the easiest way to backup once package has been installed? I am using Access 2019
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 22:49
Joined
Feb 28, 2001
Messages
27,148
Easiest? Perhaps either of two solutions would work for you.

1. Make a batch file that can be launched as an individual process. Schedule it to run at a particular time of day when no one is/should be in the DB. If you want to get really fancy, a VB script can even compute a date suffix for the file name so you can date-tag the file. Have the file check for the existence of the lock file. If no lock, the file is not busy, so just make a complete copy of the BE file.

2. Make a separate Access standalone file that does the file copy and file name manipulation for you. Again, check for the lock file of the target app before deciding to make the file copy. Again, make a complete copy.

In NEITHER case do you EVER want to make a backup of part of the file. I.e. don't even BEGIN to think about making a backup from within the app. Always make the backup from outside of the app. Always make it a monolithic copy operation.

In EITHER case you can launch the backup operation using Windows Task Scheduler set for daily operation at your chosen time. Note that if you use the "Access standalone app" to do the backup, you need to schedule Access to open your app with the /X:macro-name option, and that named macro is the sequence of steps to do the file copy operation. Look up Access command line options to see more of the /X operation. IF you do it this way, ALWAYS end the named macro with an Application.Quit command, because you don't want to leave copies of Access "dangling" after the backup.

IF it happens that you have a 7 x 24 exposure, you have already screwed the pooch. Whether talking Access or ORACLE or some other DB setup, you should ALWAYS have a time set aside to make unobstructed backups. ALWAYS. Forgive the slight implied arrogance, but if your data was important enough to have to be backed up and you CAN'T set time aside for your backup, then you weren't serious about the importance of the data. I learned that from having 28 1/2 years of experience as a U.S. Navy system administrator for a big personnel database. If it is important, be prepared to make accommodations to TREAT it that way.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 20:49
Joined
Oct 29, 2018
Messages
21,455
Take a look at this, in case you can use it.

 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:49
Joined
May 7, 2009
Messages
19,229
you install Goodsync, it is Set-and-forget backup system.
 

moke123

AWF VIP
Local time
Yesterday, 23:49
Joined
Jan 11, 2013
Messages
3,912
I use the procedure in the link @theDBguy provided (with slight customization of passing the backup directory path to the procedure).
In the application folder I create a directory to hold the back ups.
Using fso I iterate through that folder and find the created date of the latest backup. If it is older than a certain number of days, I make a new backup with a call to TheDBGuys procedure. I also check for back up files older than a certain number of days and delete them. (you can comment out this part if you want to save all backups)

Code:
Public Sub BackEndBackUps()
   
    Dim fld As Folder, fil As File
    Dim dteMax As Date, flg As Boolean
    Dim objFiles As Object, lngFileCount As Long
    Dim FolderPth As String
   
    Dim fso As New FileSystemObject

    FolderPth = CurrentProject.Path & "\DataBackups" 'path to backup folder

    'If the backup folder doesn't exist, create it
    If Len(Dir(FolderPth, vbDirectory)) = 0 Then
        MkDir FolderPth
    End If

    dteMax = #1/1/2000#

    Set fld = fso.GetFolder(FolderPth)

    'get the most recent created date of all the backups in the folder
    For Each fil In fld.Files
        If dteMax < fil.DateCreated Then
            dteMax = fil.DateCreated
        End If
    Next

    Set objFiles = fso.GetFolder(FolderPth).Files

    lngFileCount = objFiles.Count

    'check if latest backup is older than a certain number of days
    For Each fil In fld.Files

        If DateDiff("d", dteMax, Date) > 6 Then   'you can change the numeric value to the number of days between backups
       
            flg = True

        End If

    Next

    If flg = True Or lngFileCount = 0 Then
        BackUpAndCompactBE FolderPth          'Call to the Back up procedure
    End If

    'if backup file is older than a certain number of days, delete it
    For Each fil In fld.Files

        If DateDiff("d", fil.DateCreated, Date) > 28 Then   'you can change the numeric value to the number of days before deleted

            fil.Delete

        End If
    Next

End Sub
 

bastanu

AWF VIP
Local time
Yesterday, 20:49
Joined
Apr 13, 2010
Messages
1,402
Please feel free to have a look at my free utility that can be scheduled using the Windows scheduler (task manager):
It copies the network file locally to do the compact as doing it on the network drive is not recommended in case of a network interrupt that can leave it corrupt.
Cheers,
 

Users who are viewing this thread

Top Bottom