Ok, my code for my Backup module works well via Copyfile.

Here's what it can do (current):


Backup my Database but using the date function as its filename
Restore my backup file only if the filename is Database.mdb


Here's a screenshot of the prog:
http://img262.imageshack.us/i/restore.png/

and the backup files:
http://img152.imageshack.us/i/backups.png/

Note: If I backup my database on the same day, it will just delete the file with the same date.

Heres my code (Backup):

Public Sub DBBackup()

'On Error GoTo err:

    Dim myFile As New FileSystemObject
    
    Dim myTrue As String
    Dim myTemp As String
 
        
    If myFile.FolderExists(App.Path & "\Backup") = False Then
        myFile.CreateFolder App.Path & "\Backup"
    End If

    Set myFile = Nothing
    

    myTrue = App.Path & "\Backup\" & Format$(Date, "mmmm-dd-yyyy") & ".mdb"
    If myFile.FileExists(myTrue) = True Then
        myFile.DeleteFile myTrue, True
    End If
    
    
    myTemp = myTrue & Now - DateValue(Now) & GetTickCount
    If myFile.FileExists(myTemp) = True Then
        myFile.DeleteFile (myTemp)
    End If
            
     myFile.CopyFile App.Path & "\Database.mdb", myTrue, False
        
    MsgBox "Database Backup Process Complete", vbInformation, "Information"
    lblCBK.Caption = "Backup process complete."
    
    
    Form2.Enabled = True
    cmdClose.Enabled = True
    
    Exit Sub
err:
    MsgBox err.Description, vbCritical
End Sub

Here's what I want the module to do:

At backup, it would rename the file to Database.mdb w/out deleting the file w/ the
same name (if thats possible) or not delete it because of different in time the
backup was created.

It can create a multiple backup a day w/out replacing other files.


Please don't tell me to use Encode/Decode Binary methods.

Thanks in advance.

@Abe, one question. Why do you want to make multiple backups for your database? The code you are currently using checks the database size and compare to the new size. If there is a difference, it will overwrite the old one.

For modification purposes sir.

Let's say I Backup my database at 9:00, then I had to add a User at 10:00, so rather than replacing the first backup, it would just create another backup file.

So that I can Restore any of the database backup if there is any need of looking at records on earlier date.

Still keeping the Database.mdb (still, if possible).

count the occurrence and suffix (1) to database name....similarly, again count occurrence and add (2) and increment it till u logout.

commented: It's a pleasure. +4

dsp has the correct idea.:)

I would create a "master" database that will be updated daily, with separate individual databases copied and numbered from 1 to say 8 which was created every hour and named db1 and the date for instance and so on.

Your problem is that you will unfortunately overwrite the master every time that you reference it in your code, so there is no way around that...

thanks andre i appreciate it really.

Uhm yes i guess i got that one now.

Next is the restoration of a DB (one which is selected by the use).

My DB Backup name would be January-04-2010.mdb (Because of the date code), if i select this DB and restore it, it would be renamed to Database.mdb so that it will replace the current DB which is on my App's path.

Thanks again..

Cool, happy coding.:)

Please mark as solved, thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.