1 backup.inc | backup_delete($backup_name) |
Delete a backup from the backup directory by its directory name.
Parameters
string $backup_name: The name of the backup (same as the backup directory).
Return value
bool: TRUE if the backup was deleted, FALSE on failure.
File
- core/
includes/ backup.inc, line 599 - Contains functionality related to creating and restoring site backups.
Code
function backup_delete($backup_name) {
// Validate that the backup exists within the backup directory. This prevents
// deleting any kind of file with this function other than a backup.
$backups = backup_directory_list();
$success = FALSE;
if (!isset($backups[$backup_name])) {
return FALSE;
}
$backup = $backups[$backup_name];
// Final safety check, only delete valid backups (those with correct JSON
// files describing their contents). The "backup_directory" key is set
// specifically in backup_directory_list(), it is not read from the JSON.
if ($backup['valid'] && is_dir($backup['backup_directory'])) {
$success = file_unmanaged_delete_recursive($backup['backup_directory']);
}
return $success;
}