Question

Which tables and which contained data can I omit from SQL backup?

There seem to be many different answers to this around Internet, but most answers do not make it clear whether they are specifying that tables can be omitted or the data in the tables. My guess is it comes down to knowing which modules are robust and will re-create their own empty tables if they aren't there.

Without knowing the code innards of every module that is a possible candidate for omission, is there a good answer to the question?

At the moment, my intention is to start with the default lists built into Backup and Migrate; for anything else, I think could be omitted then omit the data from such tables not the table itself (playing safe). It could be something published in the documentation for a module but I don't think it is. Is there a completely definitive list somewhere?

It's very confusing seeing lists of "you can omit these" without knowing whether it's referring to the tables or their content.

Was it helpful?

Solution

You can omit the data from some tables. You cannot omit the actual table creation.

Tables for modules are created in one of two ways. Either when the module is first enable via hook_schema or when an update hook (hook_update_N) runs. Tables in hook_schema are only created when the module is first enabled. After an update hook is run the system table is updated with the schema version so it's not run twice.

You can't expect modules (or core) to just recreate tables that they expect to exist but are missing on the fly. It's nothing to do with being robust - this is just how Drupal works. Also it would be very inefficient to check a table exists before running every query. You would be doubling the number of queries you have to run. This would be crazy!

If you have any missing tables you would need to disable, uninstall and then re-install the module to fix it.

This question has suggestions of which which tables contain data that can be excluded.

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top