question

jctronicsshiva avatar image
jctronicsshiva asked

Database schema change and DB restore

I have a general design/strategy doubt. Suppose i have taken a backup of the DB some days back. Now i have added a column in a table of the DB and my bussiness layer is also using that value. Now i want to restore the old backup which i had taken. Will it conflict since the present schema is different?. In this case whats the approach? should there be some mapping with DB versions and Bussiness layer version or something similar. I would like to know the ideal design approach here.
restoreupgradedatabase-designarchiving
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Kev Riley avatar image
Kev Riley answered
If you restore the backup then that is a complete replacement of the database, to the version that is included in the backup - i.e. you will lose the column. And all the changes you have made (additions, deletions, updates) since. Presume you are wanting to restore to retrieve some old data? To get round the issue now, restore the database to a different name, and copy the data that you need. What I'm confused about is you asked about the 'design approach' - do you want to be able to do this regularly?
4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

To handle the 4th concern - simply increase the frequency of the backups. If you are making schema changes but relying on older backups for resilience, your DR strategy is flawed!
1 Like 1 ·
Sorry. design approach might not be a right word. If the data is huge, copying will take time . isn't it? how about renaming the old DB to some other DB or dropping it ? and renaming the present with that name, is it possible?
0 Likes 0 ·
You can rename the database, but then you are in the same situation - you'll have a 'live' database without the recent table changes. What is the reason for wanting to do this?
0 Likes 0 ·
Basicallyi have 2-3 requirements. 1. If i get any issue in a client PC, i can ask them to take the backup of the DB amd send it to me. I will restore in my DB and check the issue.(In case some weird issue comes up!) 2. when i want to replace the hardware. then i can merely copy the DB file and restore 3. if i want to take a report at a later point of time i want to load the achived file and load it in a dummy table and take the report. 4. database is corrupted , then i load a previous backup which is stored. But the present schema is different. how to go ahead in this situation. I think only the 4th is my concern , all other cases it should be fine.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.