1 backup.inc | backup_batch_prepare(array &$backup_targets, array $options, array &$errors) |
Prepare for a batch backup process, ensuring requirements are met.
Parameters
array $backup_targets: An array of backup settings, keyed by backup name. This value is modified by reference.
array $options: Additional options to control the Backup process. See backup_batch() for the list of available keys.
array $errors: Any errors that were encountered while preparing for the backup. This value is modified by reference.
Return value
boolean: TRUE if the batch is ready to run, FALSE if errors were encountered.
File
- core/
includes/ backup.inc, line 372 - Contains functionality related to creating and restoring site backups.
Code
function backup_batch_prepare(array &$backup_targets, array $options, array &$errors) {
foreach ($backup_targets as $backup_target_name => $backup) {
if (!isset($backup_targets[$backup_target_name]['settings'])) {
$backup_targets[$backup_target_name]['settings'] = array();
}
$backup_targets[$backup_target_name]['settings'] += $options;
if (!empty($options['name'])) {
$clean_name = preg_replace('/[^a-z0-9_\-]+/', '_', $options['name']);
// Ensure the backup name is valid before proceeding.
if ($clean_name != $options['name']) {
$errors[] = t('Invalid backup name: "@name", only letters, numbers, underscores and dashes are allowed.', array('@name' => $options['name']));
return FALSE;
}
$backup_targets[$backup_target_name]['settings']['backup_directory'] = backup_get_backup_directory() . '/' . $options['name'];
}
if (empty($backup['enabled'])) {
unset($backup_targets[$backup_target_name]);
}
elseif (!backup_prepare($backup_target_name, $backup['target'], $backup_targets[$backup_target_name]['settings'], $errors)) {
return FALSE;
}
}
if (empty($backup_targets)) {
$errors[] = t('No backup targets selected.');
return FALSE;
}
return TRUE;
}