Hi,

it would be an nice feature if it is possible to backup only the tables containing the db_prefix stored in the settings.php:

Here is my workaround. I've changed the function "_get_tables()" at the file "destinations.db.mysql.inc":

  /**
   * Get a list of tables in the db.
   */
  function _get_tables() {
    global $db_prefix;
    $len=strlen($db_prefix);
    $out = array();
    // get auto_increment values and names of all tables
    $tables = db_query("show table status");
    while ($table = db_fetch_array($tables)) {
      if (substr($table['Name'],0,$len)==$db_prefix) $out[$table['Name']] = $table;
    }
    return $out;
  }

It's only a quick and dirty solution for my problem. Is there a way to put a checkbox for this into the profile creation?

Greetings
Carsten

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fietserwin’s picture

I added support for honorating the $db_prefix (empty, string or array).
The patches attached are based on the March 25 6.x-2.x-dev version.
Basic ideas behind the solution:

  • Allow to specify the tables to backup using (SQL) wildcards
  • Allow to specify inclusion as well as exclusion
  • Default values based on the contents of $db_prefix: the default prefix with a % wildcard added, the other prefixes (for specific tables) without wildcard
  • Allow for easy editing by using a texarea with 1 specification per line. A method often seen in Drupal, e.g. defining the nodes a block should be visible on

The nodata specification is based on:

  • A texarea with 1 specification per line
  • Allow use of the * wildcard to specify multiple tables at once, e.g. cache_*

I added long help messages, also as some kind of documentation.

Internally I made the following changes:

  • Added lots of phpdoc comments on the function level. For me, to understand what current methods do in terms of what types of parameters are expected and what type of value is returned. For the methods I added myself, as documentation for others (and myself for future changes)
  • Moved a few methods from the mysql specific inc file to the general destinations.db.inc file.
  • Changed the backup algorithm a bit: first get a list of all tables to backup and whether their data is to be backed up as well, only then start the real (and db dependent) backup.
  • Removed an imo duplicate switch db call in the main backup method (backup_to_file).

If you like this new way, I will be glad to further integrate the 2 alternative ways of specifying the tables to backup (the already existing one and my new one). I’m thinking of using the 2 texarea’s with some buttons to fill the 1st texarea. One button to specify all tables (just %, ‘db driven backup’), one to fill it with all tables listed separately listed (old way, ‘fully customizable backup’) and one based on $db_prefix (new way, ‘Drupal $db_prefix based backup’).

However, to do so, some upgrading code will probably be needed to convert the contents of the current selects to content for textarea’s. Also, to further integrate this, more changes will probably be needed, as well as additional tests. I’m willing to help with this as well.

Please contact me personally if you would like me to help add new features and resolve existing issues. I’m an experienced (PHP) programmer and am now trying to get a grip on programming with the Drupal API. IMHO The best way to do so is by working on real world modules, that’s why I want to invest some time in this module.

couturier’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

Drupal 6 and Backup and Migrate 6 are no longer supported. Please re-post in the 8.x-4.x-dev branch if still desired.