You are here

function backup_migrate_get_saved_backups in Backup and Migrate 7.3

Same name and namespace in other branches
  1. 8.3 backup_migrate.module \backup_migrate_get_saved_backups()

List the previously created backups from across multiple destinations.

2 calls to backup_migrate_get_saved_backups()
backup_migrate_ui_manual_restore_form in ./backup_migrate.module
The restore/import upload form.
backup_migrate_ui_saved_backups in ./backup_migrate.module
List the previously created backups from across multiple destinations.

File

./backup_migrate.module, line 1503
Backup and restore databases for Drupal.

Code

function backup_migrate_get_saved_backups($refresh = FALSE) {
  require_once dirname(__FILE__) . '/includes/destinations.inc';
  require_once dirname(__FILE__) . '/includes/profiles.inc';
  require_once dirname(__FILE__) . '/includes/sources.inc';
  drupal_add_css(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.css');
  $remote = FALSE;
  $now = $fetch_time = time();
  $out = '';
  $files = $sort = array();
  foreach (backup_migrate_get_destinations('list files') as $destination) {
    $dest_id = $destination
      ->get_id();
    $dest_files = $destination
      ->list_files();
    if ($dest_files) {
      $location = l($destination
        ->get_name(), BACKUP_MIGRATE_MENU_PATH . '/settings/destination/list/files/' . $dest_id);
      if ($destination
        ->get('remote')) {
        $location .= $destination
          ->get('remote') ? ' <strong class="backup-migrate-tag">(' . t('offsite') . ')</strong>' : '';
        $remote = TRUE;
      }

      // Refresh the destination.
      if ($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) {
        $dest_files[$id]->file_info['bam_other_safe'][t('Location:')] = $location;
        $sort[$dest_id . '/' . $id] = $file
          ->info('filetime');
        $files[$dest_id . '/' . $id] = $file;
      }
    }
  }
  array_multisort($sort, SORT_DESC, $files);
  return array(
    $files,
    $fetch_time,
    $remote,
  );
}