<?php
$host = 'localhost';
$username = 'seoposuser';
$password = '@#seopossystem2040';
$database = 'koreauto_seoposdb';


$backupFile = 'database_backup.sql';


$command = "mysqldump --host=$host --user=$username --password=$password $database > $backupFile";


exec($command, $output, $returnValue);


if ($returnValue === 0) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename="' . basename($backupFile) . '"');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($backupFile));
    readfile($backupFile);
    unlink($backupFile);
    exit;
} else {
    echo "Error: Database backup failed";
}
?>