Last active
March 28, 2023 08:13
-
-
Save joviczarko/363027b2bdd32125d0390ec13d97e029 to your computer and use it in GitHub Desktop.
Automatic MySQL database backup (dump) bat file for wamp server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
For /f "tokens=2-4 delims=. " %%a in ('date /t') do (set mydate=%%c-%%a-%%b) | |
For /f "tokens=1-3 delims=.:," %%a in ("%TIME%") do (set mytime=%%a-%%b-%%c) | |
set TIMESTAMP=%mydate%_%mytime% | |
REM Export all databases into file E:\wamp64\backup\database_backup.[year][month][day].sql | |
"E:\wamp64\bin\mysql\mysql5.7.14\bin\mysqldump.exe" --all-databases --result-file="E:\wamp64\backup\database_backup_%TIMESTAMP%.sql" --user=root | |
REM Change working directory to the location of the DB dump file. | |
E: | |
CD \wamp64\backup\ | |
REM Compress DB dump file into CAB file (use "EXPAND file.cab" to decompress). | |
MAKECAB "database_backup_%TIMESTAMP%.sql" "database_backup_%TIMESTAMP%.sql.cab" | |
REM Delete uncompressed DB dump file. | |
DEL /q /f "database_backup_%TIMESTAMP%.sql" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment