#!/usr/bin/env php
<?php
// Sauvegarde de la base de données MySQL
$backup_dir = __DIR__ . '/../backups/';
if (!is_dir($backup_dir)) {
    mkdir($backup_dir, 0755, true);
}

$filename = $backup_dir . 'backup_' . date('Y-m-d_H-i-s') . '.sql';

$db_host = 'localhost';
$db_user = 'root';
$db_pass = '';
$db_name = 'btp_auto_controle';

$command = "mysqldump -h $db_host -u $db_user -p$db_pass $db_name > $filename 2>&1";
system($command, $output);

echo "Sauvegarde effectuée : $filename\n";