Wrong list of tables used when backing up more than one db

Created on 23 January 2024, 11 months ago
Updated 26 January 2024, 11 months ago

Edited title to match new observations. See first comment for updated info

Using Backup and Migrate v7.x-3.10

Hi. I feel silly asking this, for a great module that has been in use for so long

I inherited management of my drupal 7 site, and it probably had Backup and Migrate installed when it was a drupal 6 site

I want to be able to back up other db's, in addition to drupal's db, via Backup and Migrate

I added some extra db's to drupal's settings.php file, and Backup and Migrate can see them

But in the Settings Profiles config page, in the section for my additional, non-drupal, db, the choices in the two "Exclude" lists are drupal tables, and not the tables in db the section pertains to. Eg: the title of the section is "wp_new:default: mysql://[usr]@localhost/[db] Backup Options" (where wp_new is a wordpress db), but when I open the section, the two "Exclude" lists are all the drupal files in my default db.

Is there a way to get the Exclude lists to be read from the associated db?

I see a filters field in backup_migrate_profiles which seems to hold details for all settings profiles, not just for the row in which a value lives. And the value does list all the tables in the drupal db. Should I manually edit this field in the db? Doesn't seem the desirable way to do things.

I did see the issue from 10 years ago about problems getting the default db's backup profile settings to stop being merged with other db profiles. The patch for that has been long-ago merged into the code base, and that did not solve this issue for me
https://www.drupal.org/project/backup_migrate/issues/2290707 β†’

Thanks for any advice

πŸ› Bug report
Status

Active

Version

3.10

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States hanksterr7

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @hanksterr7
  • πŸ‡ΊπŸ‡ΈUnited States hanksterr7

    I have a solution (?) to the issue. I doubt this is the right way to fix this, but i offer this if anyone else has similar issues

    This function lives in includes\sources.mysql.db.inc

    If fetches the tables and views for a "source"

    The problem is, it builds a static list of tables for a source. If you have multiple sources that are part of a backup job, and the sources have different tables, the static list built from the first source gets used for the subsequent sources. That causes the wrong list of tables to be looked at when trying to back up the subsequent sources

    I reset $tableData to null so it would always get rebuilt when this function is called

    Probably could have just removed the "static" attribute

    Don't know what unintended consequences there are to this approach, but it now allows me to get all my db's backed up

      /**
       * Get a list of table and view data in the db.
       */
      protected function get_table_data() {  
        static::$tableData = null; // add this
      
        if (empty(static::$tableData)) {
          $tables = $this->query('SHOW TABLE STATUS')->fetchAll(PDO::FETCH_ASSOC);
          foreach ($tables as $table) {
            // Lowercase the keys because between Drupal 7.12 and 7.13/14 the
            // default query behavior was changed.
            // See: http://drupal.org/node/1171866
            $table = array_change_key_case($table);        
            static::$tableData[$table['name']] = $table;
          }
        }
        return static::$tableData;
      }
  • πŸ‡ΊπŸ‡ΈUnited States hanksterr7
Production build 0.71.5 2024