DB backup script

:: preparing date and time

        for /f “tokens=2 delims==” %%a in (‘wmic OS Get localdatetime /value’) do set “dt=%%a”

set “YYYY=%dt:~0,4%” & set “MM=%dt:~4,2%” & set “DD=%dt:~6,2%”

set “HH=%dt:~8,2%” & set “Min=%dt:~10,2%” & set “Sec=%dt:~12,2%”

set “timestamp=%YYYY%-%MM%-%DD%_%HH%%Min%%Sec%”

       ::  mysql dump location
set dumpExePath=C:mysqlbinmysqldump.exe

        :: host location or IP
set host=localhost

set portNumber=3306

set userName=userName

set password=mypassword

set DBName=myDB

set backupLocation=C:myLocation

START %dumpExePath% -h %host% –port %portNumber% -u %userName% -p %password% %DBName% -r %backupLocation%MyDB_backup_%timestamp%.sql

Leave a Reply

Your email address will not be published. Required fields are marked *

Enable Notifications OK No thanks