<?php
require_once __DIR__ . '/../../app/includes/auth.php';
require_auth();
require_admin();
verify_csrf();
require_once __DIR__ . '/../../app/services/DatabaseBackupService.php';
try {
    $filename = (string)post('file', '');
    $path = DatabaseBackupService::resolve($filename);
    unlink($path);
    log_activity('database_backup_deleted', 'Deleted database backup ' . $filename);
    flash('success', 'Database backup deleted successfully.');
} catch (Throwable $e) {
    flash('error', $e->getMessage());
}
redirect('/backups/index.php');
