Windows mysql backup script

Use the below Windows Mysql backup script (.bat script) to add it as either a scheduled task, or just run it to have it make mysql database backups of all your selected mysql host databases.

  1. Replace
    Set MysqlHost=YourMysqlHost Set MysqlUser=YourMysqlUser Set MysqlPass=YourMysqlPass Set DirForBackups=C:MysqlBackups
    with your values;
  2. Save the file as "mysql_databases_backup_script.bat" and place to a location that you can easily get to. e.g "C:MysqlBackupScriptmysql_databases_backup_script.bat"
  3. You can use it on demand e.g click on the script where ever you place it or the way we use it is as a scheduled task that will run at your specified time interval and generate backups of your MYSQL databases for safe keep.

Download the script

Set MysqlHost=YourMysqlHost Set MysqlUser=YourMysqlUser Set MysqlPass=YourMysqlPass Set DirForBackups=C:MysqlBackups @For /F "tokens=2,3,4 delims=/ " %%A in ('Date /t') do @( Set Month=%%A Set Day=%%B Set Year=%%C ) Set count = 1 @echo DAY = %Day% @echo Month = %Month% @echo Year = %Year% @For /F "tokens=* delims=/ " %%A in ('mysql -h%MysqlHost% -u%MysqlUser% -p%MysqlPass% -e"SHOW DATABASES"') do @( @Echo Starting Backup for database - "%%A" if NOT EXIST %DirForBackups%%Year%_%Month%_%Day% @( @Echo I am creating Directory "%DirForBackups%%Year%_%Month%_%Day%" MKDIR "%DirForBackups%%Year%_%Month%_%Day%" ) @mysqldump -h%MysqlHost% -u%MysqlUser% -p%MysqlPass% --databases %%A > "%DirForBackups%%Year%_%Month%_%Day%%%A_%Year%_%Month%_%Day%_backup.sql" @Echo Done Backup for database - "%%A" )

Latest News

Clients Say

  • Neil Acheampong

    UnicornCMS to me is the fastest and easiest to use platform out there. I am not a progra...

  • Mark McFarlan

    They give us a great service for the best price. Their quick and proficient support was a...

  • Mike

    You guys are really great! Using your services is wonderful. I already recommended your C...

  • George

    I just wanted to drop in and provide testimony to the excellent web design services you g...

Latest Articles