XAMPPMySQL

XAMPP – Batch script to backup all MySQL databases

Create a the folder c:\xampp\backup

Create the file mysql_all_databases.bat inside c:\xampp with the following contents

@ECHO OFF

set TIMESTAMP=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%

REM Export all databases into file C:\xampp\backup\databases.[year][month][day].sql
"C:\xampp\mysql\bin\mysqldump.exe" --all-databases --result-file="C:\xampp\backup\databases.%TIMESTAMP%.sql" --user=root

REM Change working directory to the location of the DB dump file.
C:
CD \xampp\backup\

REM Compress DB dump file into CAB file (use "EXPAND file.cab" to decompress).
MAKECAB "databases.%TIMESTAMP%.sql" "databases.%TIMESTAMP%.sql.cab"

REM Delete uncompressed DB dump file.
DEL /q /f "databases.%TIMESTAMP%.sql"

Run the file!