|
-
Sep 10th, 2002, 11:07 AM
#1
Thread Starter
Addicted Member
Backup Access database automatically
Hi,
I need to backup my Access database on every Friday night. Does anyone has any idea how to go about doing it? Do we actually need to keep our application active all the time inorder to achieve this requirement ? Thanks !
-
Sep 10th, 2002, 11:11 AM
#2
What do you want to back it up to?
A network drive?
A diskette?
A CD?
Tape?
VBs FileCopy would work, but only if the database is closed.
On the other hand, the CopyFile method of the FileSystemObject will copy a file, even if it is open.
-
Sep 10th, 2002, 11:12 AM
#3
Lively Member
We discovered our automatic backup wasn't backing up databases in use, (and most were in use at the backup time). We now use a housekeeping program to make a copy of the database, so that this, which is not in use, gets backed up. The mirror copy also provides a convenient short term backup.
-
Sep 10th, 2002, 11:17 AM
#4
Did you develop the "housekeeping program" that you mentioned aidan?
-
Sep 10th, 2002, 11:50 AM
#5
Thread Starter
Addicted Member
I will backup the database in the network drive.
Hack, do you have a simple example on how to use the CopyFile method? So if some users are updating data at the same time when you backup the database, will there be any problem ? How do you deal with such situation ?
aidan, how do you create a housekeeping program and how you detect whether the database is in used ?
Actually, my main concern is that, I can I do it automatically?
thank in advance.
-
Sep 10th, 2002, 02:03 PM
#6
VB Code:
'Set a reference to the FileSystemObject (Microsoft Scripting Runtime)
Option Explicit
Private BkUpDb As New FileSystemObject
Private Sub Form_Load()
BkUpDb.CopyFile "c:\program files\qcap\qcap.Mdb", "W:\systems\hack\qcap.Mdb", True
End Sub
-
Sep 12th, 2002, 07:55 AM
#7
Lively Member
What hack has written is pretty much what I use. It checks to see if a folder exists with today's date on it, if it doesn't then it makes it and copies the files. It doesn' t matter if they are in use, although obviously any changes which haven't been updated yet won't be saved.
The function can be triggered manually or with a timer
Here is the code
PHP Code:
Public Function MDbackupdatabases() As Long
Dim DBname$(5)
Dim oldfolder$
Dim newfolder$
Dim t&
Dim fso As Object 'As New scripting.FileSystemObject
Set fso = CreateObject("Scripting.FileSystemObject")
oldfolder = "T:\"
newfolder = "T:\DBbackups " & format(Date, "ddMMyy")
retval = MDcreateFolder(newfolder)
If retval Then 'folder did not previously exist
DBname(0) = "Contacts2000.mdb"
DBname(1) = "Project2000.mdb"
DBname(2) = "newindexes2000.mdb"
For t = 0 To 2 'cycle through all files
fso.copyfile oldfolder & DBname(t), newfolder & DBname(t), False 'false means will not overwrite
Next t 'cycle through all files
MDbackupdatabases = 1
End If 'folder did not previously exist
-
Sep 12th, 2002, 07:58 AM
#8
Lively Member
Oops - I formatted to PHP not VB code
I am planning to improve it by making it carry out a test access of the database to check that it hasn't been corrupted before the file is copied, but I haven't got round to doing this yet.
-
Sep 12th, 2002, 03:55 PM
#9
Hyperactive Member
I'm not sure if this is exactly what you are looking for, but I use it to make copy and compact the DB at the same time.
http://support.microsoft.com/default...;en-us;Q209979
-
Sep 13th, 2002, 07:51 AM
#10
Thread Starter
Addicted Member
Thanks texas, but I am using Access 97 and Visual Basic 6. The article you provided is for Access 2000.
-
Sep 13th, 2002, 08:55 AM
#11
Even though the article if for Access 2000, I wouldn't be surprized to discover you could use the fundamentals of it for Access 97.
Give it shot and see what happens.
-
Sep 13th, 2002, 09:37 AM
#12
Hyperactive Member
I took out the timer event code and set the DB to autoexec the code when the DB opened. i.e. OnOpen event of the form. That way VB can call it or in my case I used the Scheduled Tasks wizard to run it.
-
Oct 9th, 2012, 01:52 PM
#13
New Member
Re: Backup Access database automatically
 Originally Posted by aidan
What hack has written is pretty much what I use. It checks to see if a folder exists with today's date on it, if it doesn't then it makes it and copies the files. It doesn' t matter if they are in use, although obviously any changes which haven't been updated yet won't be saved.
The function can be triggered manually or with a timer
Here is the code
PHP Code:
Public Function MDbackupdatabases() As Long
Dim DBname$(5)
Dim oldfolder$
Dim newfolder$
Dim t&
Dim fso As Object 'As New scripting.FileSystemObject
Set fso = CreateObject("Scripting.FileSystemObject")
oldfolder = "T:\"
newfolder = "T:\DBbackups " & format(Date, "ddMMyy")
retval = MDcreateFolder(newfolder)
If retval Then 'folder did not previously exist
DBname(0) = "Contacts2000.mdb"
DBname(1) = "Project2000.mdb"
DBname(2) = "newindexes2000.mdb"
For t = 0 To 2 'cycle through all files
fso.copyfile oldfolder & DBname(t), newfolder & DBname(t), False 'false means will not overwrite
Next t 'cycle through all files
MDbackupdatabases = 1
End If 'folder did not previously exist
Hi, above Aiden has added a script that backups even when the database is in use. I am looking for this exact thing for accesss. As Aiden has written this in PHP, does anyone ahve something similar for access please?
Thanks,
Ian.
-
Oct 9th, 2012, 05:50 PM
#14
Re: Backup Access database automatically
That's not PHP... it's VB... he jsut used the PHP syntax highlighter by mistake... but it's VB code all the way through.
-tg
-
Aug 10th, 2015, 08:21 PM
#15
Junior Member
Re: Backup Access database automatically
Hello guys
Code:
Public Function MDbackupdatabases() As Long
Dim DBname$(5)
Dim oldfolder$
Dim newfolder$
Dim t&
Dim fso As Object 'As New scripting.FileSystemObject
Set fso = CreateObject("Scripting.FileSystemObject")
oldfolder = "T:\"
newfolder = "T:\DBbackups " & format(Date, "ddMMyy")
retval = MDcreateFolder(newfolder)
If retval Then 'folder did not previously exist
DBname(0) = "Contacts2000.mdb"
DBname(1) = "Project2000.mdb"
DBname(2) = "newindexes2000.mdb"
For t = 0 To 2 'cycle through all files
fso.copyfile oldfolder & DBname(t), newfolder & DBname(t), False 'false means will not overwrite
Next t 'cycle through all files
MDbackupdatabases = 1
End If 'folder did not previously exist
I'm getting an error in this lines of codes
Code:
newfolder = "T:\DBbackups " & format(Date, "ddMMyy")
error is Type expected
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|