This code create db backup file, but the file name have always the same name so I need to manually rename them. How would you write a code to automatically insert the date and hours of this backup in their title? (eg: backupDB-07.08.12-18h43) or something like that?
My code:
<?
echo "backup of your database
";
$db="nom_de_ma_base";
$status=system("mysqldump --host=mysql5-1.perso --user=$_POST[login] --password=$_POST[password] $db > ../$db.sql");
echo $status;
echo "Compression du fichier.....
";
system("bzip2 -f /homez/backupDB/$db" . date("d-M-Y", time()) . ".sql");
echo "C'est fini. You can access to your database
\n
";
?>
You’re doing the date thing in the wrong place. Put the timestamp into a string variable and add that one to where the backup sql file is actually written.
The idea of putting it in a variable is that it might change between the start of the write operation, and the start of the compression operation.