I have this script to access my mysql database and do some maintenance.
I am on windows platform. Mysqldump is installed at C:\Program Files\MySQL\MySQL Server 5.7\bin and PHP.exe is installed at C:\TCAFiles\xampp\php
I have a database.php with
<?php
// Database Connection Setup
// -------------------------------------------------------
$dbhost = '127.0.0.1';
$dbname = 'dbname';
$dbuser = 'username';
$dbpass = 'password';
// -------------------------------------------------------
$db_local = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
?>
I have a cleanup.php
<?php
// Set the protection period
$ProtectionPeriod = 97;
echo "================================
Database Cleanup Started:
================================
";
include 'database.php';
// Do db backup
// -------------------------------------------------------
// if mysqldump is on the system path you do not need to specify the full path
// simply use "mysqldump --add-drop-table ..." in this case
$date = date("Y-m-d_H-i-s");
$dumpfname = 'D:\\Tinboye\\backups\\'.$dbname.'_'.$date.'.sql';
$command = "C:\\Program%20Files\\MySQL\MySQL%20Server%205.7\\bin\\mysqldump --add-drop-table --host=$dbhost --user=$dbuser --password=$dbpass exile > $dumpfname";
system($command);
echo "backup $dumpfname made
";
// delete push bikes
$sql = "DELETE FROM vehicle WHERE class = 'Exile_Bike_OldBike' OR class = 'Exile_Bike_MountainBike'";
$result = mysqli_query($db_local, $sql);
// Delete players not logged in for $ProtectionPeriod days with less than 10 total_connections
$sql = "DELETE FROM player WHERE account_uid IN (SELECT uid FROM account WHERE last_connect_at < NOW() - INTERVAL $ProtectionPeriod DAY)";
$result = mysqli_query($db_local, $sql);
// Remove empty containers not used in 48 hours
$sql = "DELETE FROM container WHERE last_updated_at <= NOW() - INTERVAL 48 HOUR AND cargo_items = '[[],[]]' AND cargo_magazines = '[]' AND cargo_weapons = '[]' AND cargo_container = '[]'";
$result = mysqli_query($db_local, $sql);
?> and a bat file to run the php script
@echo off
::=====================================================================================================================================
:: Database Housekeeping backup & clean
::=====================================================================================================================================
C:\TCAFiles\xampp\php\php.exe D:\Tinboye\servers\jnjexile\ExileCleanup\exile_cleanup.php
pause
but when i execute the script I get an error
================================
Database Cleanup Started:
The system cannot find the path specified. backup D:\Tinboye\backups\exile_dayz_2016-04-09_23-30-31.sql made
Press any key to continue . . . Terminate batch job (Y/N)?
when i go to the folder D:\Tinboye\backups there is the file created, but no data, which leads me to believe that the mysqldump is not found.
anyone see the problem here?