You are here

function backup_migrate_backup_migrate_destinations in Backup and Migrate 5.2

Same name and namespace in other branches
  1. 8.2 includes/destinations.inc \backup_migrate_backup_migrate_destinations()
  2. 8.3 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 111
All of the destination handling code needed for Backup and Migrate.

Code

function backup_migrate_backup_migrate_destinations() {
  require_once './' . drupal_get_path('module', 'backup_migrate') . '/includes/destinations.file.inc';
  $out = array();

  // Upload is scheduled backup only.
  $out[] = array(
    'destination_id' => 'upload',
    'name' => t("Upload"),
    'type' => 'browser',
    'ops' => array(
      'restore',
    ),
  );

  // Download is manual backup only.
  $out[] = array(
    'destination_id' => 'download',
    'name' => t("Download"),
    'type' => 'browser',
    'ops' => array(
      'manual backup',
    ),
  );

  // Expose the configured databases as sources.
  global $db_url;
  $urls = is_array($db_url) ? $db_url : array(
    'default' => $db_url,
  );
  foreach ((array) $urls as $key => $url) {
    $url_parts = _backup_migrate_destination_parse_url($url);
    $location = _backup_migrate_destination_glue_url($url_parts);
    $out[] = array(
      'destination_id' => 'db_url:' . $key,
      'name' => $key == 'default' ? t("Default Database") : $key . ": " . $location,
      'type' => 'db',
      'location' => $location,
      'password' => $url_parts['pass'],
      'conf_callback' => '',
      'ops' => array(
        'source',
      ),
    );
  }

  // Manual backup only destinations
  if ($location = _backup_migrate_check_destination_dir('manual')) {
    $out[] = array(
      'destination_id' => 'manual',
      'name' => $op == 'manual backup' ? t("Save to Files Directory") : t("Manual Backups Directory"),
      'type_name' => t('Manual File Directory'),
      'location' => $location,
      'save_callback' => 'backup_migrate_destination_file_save',
      'load_callback' => 'backup_migrate_destination_file_load',
      'list_callback' => 'backup_migrate_destination_files_list',
      'delete_callback' => 'backup_migrate_destination_file_delete',
      'ops' => array(
        'manual backup',
        'restore',
        'list files',
      ),
    );
  }

  // Schedule backup only destinations
  if ($location = _backup_migrate_check_destination_dir('scheduled')) {
    $out[] = array(
      'destination_id' => 'scheduled',
      'name' => $op == 'scheduled backup' ? t("Save to Files Directory") : t("Scheduled Backups Directory"),
      'type_name' => t('Scheduled File Directory'),
      'location' => $location,
      'save_callback' => 'backup_migrate_destination_file_save',
      'load_callback' => 'backup_migrate_destination_file_load',
      'list_callback' => 'backup_migrate_destination_files_list',
      'delete_callback' => 'backup_migrate_destination_file_delete',
      'ops' => array(
        'scheduled backup',
        'restore',
        'list files',
      ),
    );
  }

  // Get the saved destinations
  $result = db_query('SELECT * FROM {backup_migrate_destinations}');
  while ($destination = db_fetch_array($result)) {
    $destination['settings'] = unserialize($destination['settings']);
    $destination['db'] = TRUE;
    $out[] = $destination;
  }
  return $out;
}