<?php

$hostName = 'localhost';
$userName = 'satyahak_krunal';
$userPass = 'Krunal@7997';
$dbName   = 'satyahak_khakhi';

// Backup folder path
$backupFolder = __DIR__ . "/daily_backups"; 

// Create folder if not exists
if (!file_exists($backupFolder)) {
    mkdir($backupFolder, 0777, true);
}

// Backup file name
$backupFile = $backupFolder . "/backup_" . date("Y-m-d_H-i-s") . ".sql";

// mysqldump command
$command = "mysqldump -h {$hostName} -u {$userName} -p'{$userPass}' {$dbName} > {$backupFile}";

// Run command
system($command);

?>
