How to backup a database?

ppataki

Registered User.
Local time
Yesterday, 22:59
Joined
Sep 5, 2008
Messages
267
Dear All,

Could you please help me with how to back up a database in VBA language?

I would just need a very basic stuff that saves the currentdb as a new file, overwriting the previous backup
(no need for dialog boxes or anything, just a simple copy-paste stuff)

Your help would be very much appreciated :)
 
FileCopy "C:\ViperResides\Viper.mdb", "c:\ViperTransfer\Viper " + Format(Now, "YYYY-MM-DD") + "__" & Format(Now, "hh-mm-ss") + ".mdb"

That is copying a DB called Viper.mdb from the folder ViperResides to the folder ViperTransfer and is adding a date/time stamp to the file name.

The resulting file name looks like

Viper 2009-01-19__23-02-58

That does not overwrite the previous backup because every copy is different due to date/time stamp. To overwrite remove the date/time stamp
 
I get an error message: "Permission denied" :(

Could you please advise?

many thanks!
 
I don't know. That type of message is often associated with trying to overwrite a fiel that is set to ReadOnly but that won't be the case here. Some sort of setting you have with user permission?

See what happens if it is copied with a btach file.

To make a batch file open Notepad and paste in this

Copy \ViperResides\Viper.mdb \ViperTransfer

Pause

and obviously change the file and folder names to yours. The Pause is to keep the CMD?DOS screen open after it runs to see any errors.

Go to File and SaveAs. At the bottom select the folder you want to save it to and name the file something.bat

It must .bat as the extension.

Now go to the file and double click on it. A black DOD screen will open and it will either have 1 File Copied or some error message.
 

Users who are viewing this thread

Back
Top Bottom