function backup_migrate_drush_destination_files in Backup and Migrate 7.3
Same name and namespace in other branches
- 8.2 includes/backup_migrate.drush.inc \backup_migrate_drush_destination_files()
- 8.3 includes/backup_migrate.drush.inc \backup_migrate_drush_destination_files()
- 6.3 includes/backup_migrate.drush.inc \backup_migrate_drush_destination_files()
- 6.2 includes/backup_migrate.drush.inc \backup_migrate_drush_destination_files()
- 7.2 includes/backup_migrate.drush.inc \backup_migrate_drush_destination_files()
Get a list of files in a given destination.
1 string reference to 'backup_migrate_drush_destination_files'
- backup_migrate_drush_command in includes/
backup_migrate.drush.inc - Implements hook_drush_command().
File
- includes/
backup_migrate.drush.inc, line 265 - Drush commands for backup and migrate.
Code
function backup_migrate_drush_destination_files($destination_id = NULL) {
require_once dirname(__FILE__) . '/destinations.inc';
$destinations = array();
// Set the message mode to drush output.
_backup_migrate_message_callback('_backup_migrate_message_drush');
if ($destination_id && !($destination = backup_migrate_get_destination($destination_id))) {
_backup_migrate_message("Could not find the destination '@destination'. Try using 'drush bam-destinations' to get a list of available destinations.", array(
'@destination' => $destination_id,
), 'error');
return;
}
// Single destination required.
if ($destination) {
$destinations = array(
$destination,
);
}
else {
$destinations = backup_migrate_get_destinations('list files');
}
// Load all the files.
$rows = $sort = array();
foreach ($destinations as $destination) {
$destination
->file_cache_clear();
$dest_files = $destination
->list_files();
foreach ($dest_files as $id => $file) {
$info = $file
->info();
$rows[] = array(
check_plain($info['filename']),
$destination
->get_id(),
format_date($info['filetime'], 'small'),
format_interval(time() - $info['filetime'], 1),
format_size($info['filesize']),
);
$sort[] = $info['filetime'];
}
}
$headers = array(
array(
dt('Filename'),
dt('Destination'),
dt('Date'),
dt('Age'),
dt('Size'),
),
);
if (count($rows)) {
array_multisort($sort, SORT_DESC, $rows);
drush_print_table(array_merge($headers, $rows), TRUE);
}
else {
drush_print(dt('There are no backup files to display.'));
}
}