Restore from Backup

7 posts by 3 authors in: Forums > CMS Builder
Last Post: December 1, 2022   (RSS)

I want to make sure of something before I restore a new install db from backups from old site.

I have tables on my new install that contain fields that didn't exist in the old database tables. The tables are in other ways unchanged.

I wish to make sure that if I "restore" those tables from backups from the old site, my new table fields will not ne deleted, but just the old data imported into their appropriate fields.

Thanks.

By Dave - November 14, 2022

Hi pgblast, 

If you restore a backup file on a site with a different table structure it will overwrite all the data and remove any new columns you created, but then when you click on "Section Editors" it will recreate any fields that exist in CMSB but not in the backup files.  But not the data.

It's always a bit tricky when your source and destination backup/restore targets are out of sync.  To be extra careful I'd make sure you have backups of both the old and new sites before making any changes.  

If you can let me know some more specific details on what you're trying to do and I can offer some suggestions if needed.

Dave Edis - Senior Developer
interactivetools.com

Dave:

Thanks for the response. What I am talking about is the following.

I have an application with  large number of tables originally created in CMSB. The old version of the application and the supporting database are currently live on a public server.

In order to update the client's old site, I earlier created an updated CMSB install on a VPS account we are using as a development machine and restored the blank database with a backup generated on the old public site using CMSB.

Since then, as I have re-written the application code on the development machine, I have needed to add some new fields to some of the development machine's tables. However, in the time since I first created the development version of the app, many data changes have taken place on the old machine.

I need to be able to get the data from the old machine onto the new and thought I could backup each table individually and then use that backup to "resore" the same table on the development machine. I was hoping that this process would add data from fields that the tables have in common and just leave new fields alone (or empty) on the new machine.

You appear to be saying that this is not the case, and that I will lose the new fields I added to the development database.

Is that correct?

Thanks.

Hi Dave:

Any followup thoughts on this issue?

Thanks

pgplast

By Dave - November 17, 2022

Hi pgplast,

I think it will do what you want, but best way to tell is to backup everything on both sides and then give it a try.

CMSB stores the section field "settings" (fieldnames, types, etc) under /data/schema/ and the field "data" in the MySQL backup files.

Here's what will happen if you restore a mismatched backup file and /data/schema/ folder:

  • The backup file will delete any tables it's restoring and recreate them, so any "data" in the tables will be lost
  • The backup file will recreate all the fields and data, whether or not the /schema/ files match it
  • Then, when you go into: Admin > Section Editors...
    • CMSB will check the schema files and automatically "create" any fields that are defined in the /schema/ files but not in the database
    • Any fields in the SQL backup but not in the schema will NOT be deleted, but shown as "Unknown Field" 
    • You can then click "create" beside those unknown fields to specify what type of field they should be shown as in CMSB

We did our best to design the restore system so it's error-resistant and never deletes data when that can be avoided so as to prevent issues.

I think that will cover everything you need.  Let me know any questions and how it goes.

Thanks!

Dave Edis - Senior Developer
interactivetools.com

By pgplast - December 1, 2022

Dave:

I was able to accomplish the move without difficulty.

To make things go more smoothly, I created the new fields for the tables in the old database before backing up and restoring on the new computer.

I suspect that this was unnecessary, but the process went smoothly and my data is successfully transfered.

Thanks for your help.