function backup_migrate_perform_backup in Backup and Migrate 7.2
Same name and namespace in other branches
- 8.4 backup_migrate.module \backup_migrate_perform_backup()
- 8.2 backup_migrate.module \backup_migrate_perform_backup()
- 8.3 backup_migrate.module \backup_migrate_perform_backup()
- 5.2 backup_migrate.module \backup_migrate_perform_backup()
- 6.3 backup_migrate.module \backup_migrate_perform_backup()
- 6.2 backup_migrate.module \backup_migrate_perform_backup()
- 7.3 backup_migrate.module \backup_migrate_perform_backup()
- 5.0.x backup_migrate.module \backup_migrate_perform_backup()
Perform a backup with the given settings.
4 calls to backup_migrate_perform_backup()
- backup_migrate_drush_backup in includes/
backup_migrate.drush.inc - Backup the default database.
- backup_migrate_schedule::cron in includes/
schedules.inc - Perform the cron action. Run the backup if enough time has elapsed.
- backup_migrate_ui_manual_backup_perform in ./
backup_migrate.module - Perform an actual manual backup and tell the user of the progress.
- _backup_migrate_backup_with_defaults in ./
backup_migrate.module - Backup the database with the default settings.
File
- ./
backup_migrate.module, line 697 - 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_perform_backup(&$settings) {
backup_migrate_include('destinations', 'files', 'filters');
timer_start('backup_migrate_backup');
// If not in 'safe mode', increase the maximum execution time:
if (!ini_get('safe_mode') && strpos(ini_get('disable_functions'), 'set_time_limit') === FALSE && ini_get('max_execution_time') != 0 && ini_get('max_execution_time') < variable_get('backup_migrate_backup_max_time', 1200)) {
set_time_limit(variable_get('backup_migrate_backup_max_time', 1200));
}
$timestamp = '';
if ($settings->append_timestamp && $settings->timestamp_format) {
$timestamp = format_date(time(), 'custom', $settings->timestamp_format);
}
$filename = _backup_migrate_construct_filename($settings->filename, $timestamp);
$file = new backup_file(array(
'filename' => $filename,
));
if (!$file) {
backup_migrate_backup_fail("Could not run backup because a temporary file could not be created.", array(), $settings);
return FALSE;
}
// Register shutdown callback to deal with timeouts.
register_shutdown_function('backup_migrate_shutdown', $settings);
$file = backup_migrate_filters_backup($file, $settings);
if (!$file) {
if (_backup_migrate_check_timeout()) {
backup_migrate_backup_fail('Could not complete the backup because the script timed out. Try increasing your PHP <a href="!url">max_execution_time setting</a>.', array(
'!url' => 'http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time',
), $settings);
}
else {
backup_migrate_backup_fail("Could not complete the backup.", array(), $settings);
}
return FALSE;
}
$file = backup_migrate_destination_save_file($file, $settings);
if (!$file) {
backup_migrate_backup_fail("Could not run backup because the file could not be saved to the destination.", array(), $settings);
return FALSE;
}
// Backup succeeded,
$time = timer_stop('backup_migrate_backup');
$message = '%source backed up successfully to %file in destination %dest in !time ms. !action';
$params = array(
'%file' => $filename,
'%dest' => $settings
->get_destination_name(),
'%source' => $settings
->get_source_name(),
'!time' => $time['time'],
'!action' => !empty($settings->performed_action) ? $settings->performed_action : '',
);
if (($destination = $settings
->get_destination()) && ($links = $destination
->get_file_links($file
->file_id()))) {
$params['!links'] = implode(", ", $links);
}
backup_migrate_backup_succeed($message, $params, $settings);
return $file;
}