Auto Backup (1 Viewer)

bhelmy

Registered User.
Local time
Tomorrow, 01:57
Joined
Dec 6, 2015
Messages
62
Hi all
Need database to make self-backup every day in the same time
 

Minty

AWF VIP
Local time
Today, 23:57
Joined
Jul 26, 2013
Messages
10,371
Schedule a copy job in the windows task scheduler.
 

Ranman256

Well-known member
Local time
Today, 18:57
Joined
Apr 9, 2015
Messages
4,337
you need a form. On the form is a text box, txtStart, that holds the Time of which to backup the data. (the backend I hope) txtStart = 21:00

This form has the timer property TIMER INTERVAL = 10000 (10 seconds)
So every 10 seconds vb looks at the time in the text box to see if its time to execute. If so,
it runs the code in ON TIMER event.

The code below goes into the form vbe.
Code:
PRIVATE mbIsRunning as boolean

Private Sub Form_Timer()

If txtStart = Now() And Not mbIsRunning Then
   mbIsRunning = True
   BackupDb
   docmd.close
End If


sub BackupDb()
dim vSrc, vTarg, vName, vTime


vTime = format(now(),"yymmdd-hhnn")
vName = "MyDb-BE.accdb"
vSrc = "\\server\folder\"
vTarg = "\\server\backup folder\" & vTime & "_" & vName 

Copy vSrc, vTarg
end sub
 

Minty

AWF VIP
Local time
Today, 23:57
Joined
Jul 26, 2013
Messages
10,371
What happens if the database isn't open?
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 08:57
Joined
Jan 20, 2009
Messages
12,852
Copy isn't ideal if the Access database might be open.

If you really want automated backups then best use a server backend such as MS SQL Server.
 

Ranman256

Well-known member
Local time
Today, 18:57
Joined
Apr 9, 2015
Messages
4,337
You can copy a db even if its open.
 

Users who are viewing this thread

Top Bottom