You are here

function backup_migrate_backup_migrate_destinations in Backup and Migrate 8.2

Same name and namespace in other branches
  1. 8.3 includes/destinations.inc \backup_migrate_backup_migrate_destinations()
  2. 5.2 includes/destinations.inc \backup_migrate_backup_migrate_destinations()
  3. 6.3 includes/destinations.inc \backup_migrate_backup_migrate_destinations()
  4. 6.2 includes/destinations.inc \backup_migrate_backup_migrate_destinations()
  5. 7.3 includes/destinations.inc \backup_migrate_backup_migrate_destinations()
  6. 7.2 includes/destinations.inc \backup_migrate_backup_migrate_destinations()

Implementation of hook_backup_migrate_destinations().

Get the built in backup destinations and those in the db.

File

includes/destinations.inc, line 100

Code

function backup_migrate_backup_migrate_destinations() {
  $out = array();

  // Add the default, out of the box destinations for new users.
  if (variable_get('backup_migrate_allow_backup_to_file', TRUE)) {
    $config = config('system.file');
    if ($file_private_path = $config
      ->get('path.private')) {
      $out['manual'] = backup_migrate_create_destination('file_manual', array(
        'destination_id' => 'manual',
      ));
      $out['scheduled'] = backup_migrate_create_destination('file_scheduled', array(
        'destination_id' => 'scheduled',
      ));
    }
    else {
      _backup_migrate_message('You must specify a private file system path in the !settings to backup to the server.', array(
        '!settings' => l(t('file system settings'), 'admin/config/media/file-system'),
      ), 'warning');
    }
  }

  // Add the browser destination for downloading to the desktop.
  if (variable_get('backup_migrate_allow_backup_to_download', TRUE)) {
    $out['download'] = backup_migrate_create_destination('browser_download');
  }
  $out['upload'] = backup_migrate_create_destination('browser_upload');

  // Expose the configured databases as sources.
  backup_migrate_include('filters');
  $out += backup_migrate_filters_invoke_all('destinations');

  /*
    global $db_url;
    $urls = is_array($db_url) ? $db_url : array('default' => $db_url);
    foreach ((array)$urls as $key => $url) {
      // Only mysql is currently supported. If more DBMs's are implemented, theis will need to be abstacted.
      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.
            unset($destination->supported_ops['scheduled backup']);
            unset($destination->supported_ops['manual backup']);
          }
          else {
            $destination->set_id('db:'. $key);
            $destination->set_name($key .": ". $destination->get_display_location());
          }
          $out[$destination->get_id()] = $destination;
        }
      }
    }
  */
  return $out;
}