I am trying to spin up a local copy of my Backdrop site using Lando. 

1) I initiated a new Lando site using my sites codebase. Got site running with fresh database

2) I enabled Backup and Migrate and pulled the database into the new site with Backup and Migrate

3) I tried to sync config, but got this message:

Configuration sync failed. The following errors were reported:
The field "field_articles_image" could not be created because a database table with the name "field_data_field_articles_image" already exists.

Should I have imported the config before importing the database?

Accepted answer

If you're doing a full site import for the first time, it's not a "config sync" so much as just pulling in the entire active config. Backup and Migrate will include all the database tables, but it doesn't (yet) handle any configuration. So right now if you have a clean Backdrop install that you want to replace with a completely different database dump and configuration, you would do the following:

  • Export the database (via mysqldump or Backup and Migrate)
  • Export the entire configuration (just zip it up or via the UI)
  • Import the database (via mysql on the command line or Backup and Migrate).
  • Copy the entire "active" config directory into the destination location. Do not use a UI or any drush commands to do the sync.

Since the database already is matched with the config, no syncing is necessary. As you found, if you try to do the sync anyway, it will fail because Backdrop thinks it needs to create the matching database tables for the new configuration files.

Comments

quicksketch's picture

If you're doing a full site import for the first time, it's not a "config sync" so much as just pulling in the entire active config. Backup and Migrate will include all the database tables, but it doesn't (yet) handle any configuration. So right now if you have a clean Backdrop install that you want to replace with a completely different database dump and configuration, you would do the following:

  • Export the database (via mysqldump or Backup and Migrate)
  • Export the entire configuration (just zip it up or via the UI)
  • Import the database (via mysql on the command line or Backup and Migrate).
  • Copy the entire "active" config directory into the destination location. Do not use a UI or any drush commands to do the sync.

Since the database already is matched with the config, no syncing is necessary. As you found, if you try to do the sync anyway, it will fail because Backdrop thinks it needs to create the matching database tables for the new configuration files.

I'm pretty sure that @quicksketch's answer is the best. 

However, I also solved the problem by using the UI to import configuration before importing the database. The downside to my method, was I had to enable all the production modules before I could import the configuration.

More specifically, I did the following:

1) dropped existing database & deleted existing settings.php
2) created a new database and start with fresh copy of settings.php
3) went through the backdrop install process
4) enabled all the modules that are enabled on production version of site
5) imported config using the UI import config feature
6) imported the database using Backup and Migrate
7) Drag and drop the necessary files into files directory

I am getting the same problem after I disable d2b module after migration is completed.   Is there any other way to deal with this problem without dropping the database?