You are here

function backup_migrate_ui_saved_backups in Backup and Migrate 6.3

Same name and namespace in other branches
  1. 8.3 backup_migrate.module \backup_migrate_ui_saved_backups()
  2. 7.3 backup_migrate.module \backup_migrate_ui_saved_backups()

List the previously created backups from accross multiple destinations.

1 string reference to 'backup_migrate_ui_saved_backups'
backup_migrate_menu in ./backup_migrate.module
Implementation of hook_menu().

File

./backup_migrate.module, line 1187
Create (manually or scheduled) and restore backups of your Drupal MySQL database with an option to exclude table data (e.g. cache_*)

Code

function backup_migrate_ui_saved_backups() {
  backup_migrate_include('profiles', 'destinations', 'sources');
  drupal_add_css(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.css');
  $remote = FALSE;
  $now = $fetch_time = time();
  $out = '';
  $files = array();
  foreach (backup_migrate_get_destinations('list files') as $destination) {
    $dest_remote = $destination
      ->get('remote');
    $label = l($destination
      ->get_name(), BACKUP_MIGRATE_MENU_PATH . '/settings/destination/list/files/' . $destination
      ->get_id());
    $remote_tag = $dest_remote ? ' <strong class="backup-migrate-tag">(' . t('offsite') . ')</strong>' : '';
    $label = '<div class="backup-migrate-destination"><span class="backup-migrate-label">' . t('Location') . ':</span> ' . $label . $remote_tag . '</div>';
    $dest_files = $destination
      ->list_files();

    // Refresh the destination
    if (isset($_GET['refresh'])) {
      $destination
        ->file_cache_clear();
    }

    // Get the file fetch time.
    if ($destination->cache_files && $destination->fetch_time) {
      $fetch_time = min($destination->fetch_time, $fetch_time);
    }

    // Add the files from this destination to the full list.
    foreach ($dest_files as $id => $file) {
      $remote = $remote || $dest_remote;
      $dest_files[$id]->file_info['description'] = $file
        ->info('description') . $label;
    }
    $files = array_merge($files, array_values($dest_files));
  }

  // Redirect if refreshing instead of displaying.
  if (isset($_GET['refresh'])) {
    drupal_goto($_GET['q']);
  }
  $fetch = $out = '';

  // Get the fetch link.
  if ($fetch_time < $now) {
    $fetch = '<div class="description">' . t('This listing was fetched !time ago. !refresh', array(
      '!time' => format_interval($now - $fetch_time, 1),
      '!refresh' => l(t('fetch now'), $_GET['q'], array(
        'query' => 'refresh=true',
      )),
    )) . '</div>';
  }

  // Render the list.
  $out .= $fetch;
  $out .= _backup_migrate_ui_destination_display_file_list($files, 20, TRUE);
  $out .= $fetch;

  // Add a remote backups warning if there are no remote backups.
  if (!$remote && user_access('administer backup and migrate')) {
    drupal_set_message(t('You do not have any offsite backups. For the highest level of protection, <a href="!addurl">create an offsite destination</a> to save your backups to.', array(
      '!addurl' => url(BACKUP_MIGRATE_MENU_PATH . '/settings/destination/add'),
    )), 'warning', FALSE);
  }
  return $out;
}