You are here

function backup_migrate_destination_db_mysql::destinations in Backup and Migrate 6.2

Same name and namespace in other branches
  1. 8.2 includes/destinations.db.mysql.inc \backup_migrate_destination_db_mysql::destinations()
  2. 8.3 includes/destinations.db.mysql.inc \backup_migrate_destination_db_mysql::destinations()
  3. 7.3 includes/destinations.db.mysql.inc \backup_migrate_destination_db_mysql::destinations()
  4. 7.2 includes/destinations.db.mysql.inc \backup_migrate_destination_db_mysql::destinations()

Declare any mysql databases defined in the settings.php file as a possible destination.

File

includes/destinations.db.mysql.inc, line 44
Functions to handle the direct to database destination.

Class

backup_migrate_destination_db_mysql
A destination type for saving to a database server.

Code

function destinations() {
  $out = array();
  global $db_url;
  $urls = is_array($db_url) ? $db_url : array(
    'default' => $db_url,
  );
  foreach ((array) $urls as $key => $url) {

    // Only mysql/mysqli supported by this destination.
    if (strpos($url, 'mysql') === 0) {
      if ($destination = backup_migrate_create_destination('mysql', array(
        'url' => $url,
      ))) {

        // Treat the default database differently because it is probably the only one available.
        if ($key == 'default') {
          $destination
            ->set_id('db');
          $destination
            ->set_name(t('Default Database'));

          // Dissalow backing up to the default database because that's confusing and potentially dangerous.
          $destination
            ->remove_op('scheduled backup');
          $destination
            ->remove_op('manual backup');
        }
        else {
          $destination
            ->set_id('db:' . $key);
          $destination
            ->set_name($key . ": " . $destination
            ->get_display_location());
        }
        $out[$destination
          ->get_id()] = $destination;
      }
    }
  }
  return $out;
}