Page 1 of 1

Backup thoeries?

Posted: Thu Jun 22, 2006 1:18 pm
by Pantcho!!
Hello,
Just wondered, when creating an application which hold databases
what things i should consider of making a backup?
I know i can just copy the DB file to somewhere else but i am talking in more of a smart way to handle this matter.
I tought of making a var in the DB that spots the last time it was updated and then when a user restores the data it tells him that he is restoring an old DB or somthing like that....

any opnions?

Thanks.

Posted: Thu Jun 22, 2006 5:02 pm
by Killswitch
How about this:

The first time a database is edited/created do nothing, but make a note that the database has been opened for the first time. Then, when it's opened again whatever changes are made make a note of the original and store. So, if a user wants to restore the database back to how it was originally you just read through the changes and convert them back to the original.

Posted: Thu Jun 22, 2006 5:02 pm
by Straker
I do that with a production database for my customers. It also has auto-backup with a time they specify. Anyway, here is an easy way:

1) Backup to a zip file into a different directory (preferably on a lan), and stamp the file name, i.e. DBBU_20060622_0100.zip;

2) Just stamp the date-time of the last backup in an INI file.

3) In the restore process, always do a pre-restore backup (time-stamped of course) just to be sure you don't stomp on anything and end up in a backup-garbage-restore-garbage loop.

hope this helps.

Posted: Thu Jun 22, 2006 5:16 pm
by Pantcho!!
Killswtich: thanks but i dont think rolling back all the commands is not smart... too complicated :? can you imagine roll back to 100 queries ?

Straker: sounds just like i tought make it in a zip file and inside the zip file i put a simple info file regarding date and time.

cool.

Posted: Thu Jun 22, 2006 5:52 pm
by Straker
here's another trick which simplifies my life:

On every table, i add 17 standard meta-data columns, but the most important are:

CREATED_BY
CREATED_DATE
CREATED_TIME
LAST_UPDATED_BY
LAST_UPDATED_DATE
LAST_UPDATED_TIME

and always stamp these columns in your DML statements. This way, you can always know when someone created a record and the last time it was updated - this can be used as an internal way to backup only those records that have changed from the last backup.

Personally, I use them to hunt down people that have messed up the database.
:twisted:

Posted: Thu Jun 22, 2006 8:22 pm
by Pantcho!!
Thanks! surely will use this tip for future use.
Currently my app if for 1 person use and it pretty simple so the first suggestion will qualify.

many thanks :P