I'm creating a database to store records of user accounts and want to have a way to automate backups. I know Access has the backup database function. Is it possible to use that so that it backups on some sort of regular basis, say every day at 5PM or something? Or would this be more of a Windows function?
4 7838 Rabbit 12,516
Recognized Expert Moderator MVP
Since you can't ensure that Access will be running all the time, I would schedule the backup through Windows.
I second Rabbit's suggestion. I use Windows' Scheduled Tasks and a VBScript to backup the databases I maintain.
If you'd like a sample script, I'll be happy to post one.
Thx it would be nice to get it Beacon. I am looking for code to backup with vba
The code isn't VBA...it's VBScript. Like Rabbit mentioned, the more reliable way to schedule the backup is using Windows, specifically Windows Scheduled Tasks.
I use a VBScript that I've placed in my C:\Temp folder and have a Windows schedule set to run it everyday at 6:00 AM. I also have written a subroutine that emails me if the script runs to completion. I guess technically it doesn't necessarily guarantee that the database will be backed up, but it has worked for me for a few years now.
I should mention that the code backs up the database every day for a maximum of 14 days. The 15th backup is deleted in an effort to save space...you can always remove that part of the code if you want to save ALL copies of the database.
Here's sample code (this code needs to be written in a text editor, like Notepad, and save with a .vbs extension...you'll also need to change the paths, folder names, and email info to match your own): -
'*********************
-
'* Main Code Block *
-
'*********************
-
-
dim strDriveLetter, strRemotePath, objNetwork, objMessage
-
-
strDriveLetter = "Z:"
-
strRemotePath = "YOUR_PATH_HERE" 'You need the literal path, not just the drive letter
-
-
set objNetwork = CreateObject("WScript.Network")
-
-
On Error Resume Next 'if drive is already mapped, go to next statement
-
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath
-
-
Call BackUpDatabase
-
-
Call CleanUpFolder
-
-
Call SendEmail
-
-
-
'*****************
-
'* End of Main *
-
'*****************
-
-
Sub BackUpDatabase()
-
-
dim strDriveLetter, strRemotePath, objNetwork
-
dim mydate, location, path, filename
-
dim filesys, destination
-
-
strDriveLetter = "Z:"
-
strRemotePath = "YOUR_PATH_HERE"
-
-
set objNetwork = CreateObject("WScript.Network")
-
-
On Error Resume Next 'if drive is already mapped go to next statement
-
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath
-
-
mydate = replace(date, "/", "-")
-
-
location = "FOLDER_PATH_AND_NAME_OF_THE_DATABASE_THAT_NEEDS_TO_BE_BACKED_UP"
-
path = "PATH_WHERE_THE_DATABASE_WILL_BE_BACKED_UP+MINUS_THE_FILE_NAME"
-
filename = "DATABASE_BACKUP_COPY_NAME"
-
-
set filesys=CreateObject("Scripting.FileSystemObject")
-
-
destination = path & filename & mydate & ".mdb"
-
-
If filesys.FileExists(location) Then
-
filesys.CopyFile location, destination
-
End If
-
-
objNetwork.RemoveNetworkDrive strDriveLetter
-
-
End Sub
-
-
Sub CleanUpFolder()
-
-
dim path, filename, filesys, choice
-
dim myArray()
-
redim myArray(45)
-
dim counter, dcounter, thedate, rdate
-
-
path = "PATH_WHERE_THE_DATABASE_WILL_BE_BACKED_UP+MINUS_THE_FILE_NAME"
-
filename = "DATABASE_BACKUP_COPY_NAME"
-
-
set filesys=CreateObject("Scripting.FileSystemObject")
-
-
dcounter = 60
-
-
for counter = 1 to ubound(myArray)
-
thedate = date - dcounter
-
-
rdate = replace(thedate, "/", "-")
-
-
rfile = path & filename & rdate & ".mdb"
-
-
if filesys.fileexists(rfile) then
-
filesys.deletefile rfile
-
end if
-
-
dcounter = dcounter - 1
-
next
-
-
End Sub
-
-
Sub SendEmail()
-
-
dim htmlOpen, htmlFontOpen, myText, htmlFontClose, htmlClose
-
-
htmlOpen = "<HTML><Body>"
-
htmlFontOpen = "<Font Face=Verdana Size=2 Color=Navy>"
-
myText = "Script Successful..."
-
htmlFontClose = "</Font>"
-
htmlClose = "</Body></HTML>"
-
-
Set objMessage = CreateObject("CDO.Message")
-
-
With objMessage
-
.Subject = "Scheduled Task Successful " & date & " -- YOUR DATABASE NAME"
-
.From = "YOUR_EMAIL_ADDRESS"
-
.To = "YOU_EMAIL_ADDRESS"
-
.HTMLBody = htmlOpen & htmlFontOpen & myText & htmlFontClose & htmlClose
-
-
'==This section provides the configuration information for the remote SMTP server.
-
'==Normally you will only change the server name or IP.
-
.Configuration.Fields.Item _
-
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
-
-
'Name or IP of Remote SMTP Server
-
.Configuration.Fields.Item _
-
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "YOUR_EXCHANGE_SERVER"
-
-
'Server port (typically 25)
-
.Configuration.Fields.Item _
-
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
-
-
.Configuration.Fields.Update
-
-
'==End remote SMTP server configuration section==
-
-
.Send
-
-
End With
-
-
End Sub
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Konrad |
last post by:
I have an internet portal based on MySql database and what I need is
to make a database backup , after each actualization of data.
I know how should PHP code look like but I have no idea how to...
|
by: newbiegca_sqlsever2000 |
last post by:
Question 1
3 GHZ CPU (Intel pentium 4) single cpu + 2 GB Memory + SCSI HDD
Database size 10 GB - How long will full database backup take if the
backup is writing a file to the hard disk...
|
by: Vincento Harris |
last post by:
I implement manual log shipping per
http://www.sql-server-performance.com/sql_server_log_shipping.asp
Full Backups are configured to overwrite current backups(backup with
init)
The process...
|
by: siliconmike |
last post by:
How do I synchronize MySQL table data of my home PC with latest data
from a remote server ?
My home PC is on a very slow internet connection, so implementing
replication will cause long time...
|
by: mxd349 |
last post by:
Operating system: Linux 7.X
DB2 version: 8.1
I am new to DB2 and I have 2 problems:
1- Although I have schedule a database backup for 9:30 PM nightly, it
runs at 10:16 PM. I have scheduled...
| |
by: Najm |
last post by:
Hi All,
I am facing this issue very frist time. I add a logical device as
following:
USE master
GO
EXEC sp_addumpdevice 'disk', 'AdvWorksData',
|
by: Bernard Dhooghe |
last post by:
Suppose a running database (DB2 UDB) with all containers being SMS
based (file system as JFS or JFS2 on AIX).
How to make a backup (online) by doing a file system backup and not a
database...
|
by: chinna |
last post by:
Hi ,
Can anybody help me in taking up the database backup. I don't have
any idea about db2 and know a bit in oracle. In oracle we can import
and export data that may be in the same database...
|
by: Varan |
last post by:
hai,
now we are using batch file for take backup at time of start services and stop services. we need option for take database backup at time
1. System Start
...
|
by: viper888 |
last post by:
Hi there,
How can I automate may database backup using query analyser?
My routine goes this way:
1. Every 5:00pm check Enterprise manager who is currenlty logged on to sql server.
2. If there...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |