Batch file for regularly executing tasks with bat

Time:2021-10-18

@echo off
set txt1=%date:~0,4%
:: current year
set txt2=%date:~5,2%
: current month
set txt3=%date:~8,2%
: current day
set txt4=%time:~0,2%
: current hour
set txt5=%time:~3,2%
: current minute
set txt6=%time:~6,2%
: current seconds
set date=%txt1%%txt2%%txt3%
set time=%txt4%%txt5%%txt6%
echo ————————————————–
echo  ————- Performing MySQL database backup————–
echo ————————————————–
echo …
echo …
echo   Export database
if exist %date%.sql del %date%.sql
c:\Progr*\mysql\bin\mysqldump –add-drop-table -c -u root -p-h  localhost  dbname >e:\%date%.sql
echo …
echo …
if exist dump%date%.7z del dump%date%.7z
echo   Zip file
7za.exe a -t7z dump%date%.7z %date%.sql -mx9
echo …
echo …
echo   Delete temporary file
del %date%.sql
echo …
echo …
echo   Backup complete!
pause