0

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.

  • How does your question differ from this one ... or from this one? – Pierre.Vriens Oct 21 '17 at 18:04
  • Pierre, I'm specifically asking about two things 1. the difference between removing the table and removing the data and 2. a definitive answer - there are many answers around but they are very confusing in this aspect. – Andy Oct 21 '17 at 19:08
  • Well, if you want to reduce the risk of your question being marked as a duplicate of either of them, I suggest you EDIT your question and explain why each of these 2 questions are not to be considered as duplicates. – Pierre.Vriens Oct 21 '17 at 19:11
  • And this text (already in the question) does not do that ? "There seem to be many different answers to this around the net but most answers do not make it clear whether they are specifying that tables can be omitted or the data in the tables." – Andy Oct 21 '17 at 19:42
  • I'm just trying to help ... let's see how this question will evolve. – Pierre.Vriens Oct 21 '17 at 20:05
0

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.

  • Yes, Drupal 7 doesn't create the tables when it finds out they don't exist anymore. I could avoid creating the cache tables because I am not using the database to store their data, but that still would not work if I were to use again the database (although, I doubt somebody would return to using the database when they found a valid alternative to using the database). The same is true for those cases where Drupal allows to select where to store data. – kiamlaluno Oct 23 '17 at 5:27
  • @andy If you find the answer helpful then you could up vote and accept it. – Felix Eve Oct 25 '17 at 2:29
  • Thanks Felix - I only just found out how to do that - in fact I'm not 100% sure it worked. Totally off topic so I hope this comment doesn't annoy people. I clicked on the up-arrow and the number momentarily changed to 1 then back to 0 (hmmmm). Clicked on the tick and that state was retained. – Andy Oct 26 '17 at 9:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.