function backup_migrate_destination_nodesquirrel::load_file in Backup and Migrate 6.3
Same name and namespace in other branches
- 8.3 includes/destinations.nodesquirrel.inc \backup_migrate_destination_nodesquirrel::load_file()
- 6.2 includes/destinations.nodesquirrel.inc \backup_migrate_destination_nodesquirrel::load_file()
- 7.2 includes/destinations.nodesquirrel.inc \backup_migrate_destination_nodesquirrel::load_file()
Load from the NodeSquirrel destination.
Overrides backup_migrate_destination::load_file
File
- includes/
destinations.nodesquirrel.inc, line 279 - Functions to handle the NodeSquirrel backup destination.
Class
- backup_migrate_destination_nodesquirrel
- A destination for sending database backups to the NodeSquirel backup service.
Code
function load_file($file_id) {
if ($destination = $this
->_get_destination()) {
backup_migrate_include('files');
$file = new backup_file(array(
'filename' => $file_id,
));
$ticket = $this
->_xmlrpc('backups.getDownloadTicket', array(
$destination,
$file_id,
));
if ($ticket && ($url = $ticket['url'])) {
// If the ticket requires authentication add our username/password to the url.
if (!empty($ticket['auth']) && ($ticket['auth'] = 'basic')) {
$parts = parse_url($ticket['url']);
$parts['user'] = @$this->dest_url['user'];
$parts['pass'] = @$this->dest_url['pass'];
$url = $this
->glue_url($parts, FALSE);
}
$out = drupal_http_request($url);
if ($out->code == 200) {
file_put_contents($file
->filepath(), $out->data);
return $file;
}
else {
$error = !empty($out->headers['x-bams-error']) ? $out->headers['x-bams-error'] : $out->error;
_backup_migrate_message('The server returned the following error: %err', array(
'%err' => $error,
), 'error');
}
}
}
return NULL;
}