Backup MYSQL databases on Windows 10 free Script

We needed a simple way to automatically Backup MySQL on windows 10 for free. Our development and testing environments required:

  • The convenience of backing up all DBs (such as This Script does).
  • Ability to exclude some of the DBs in each machine.
  • Date stamped backups, so changes are backed up each day.
  • Free and preferably open-source.
  • Easy to integrate into our existing backup scripts.

A quick search showed up nothing. We decided to expand the above mentioned script functionality to include what we require. Provided below is the important parts of the script:

:: allows for skipping of particular databases
set SkipThis=0
for /d %%f in (*) do (
    set /A Counterf=!Counterf!+1
    :: remove echo here if you like
    echo processing folder "%%f"
    pushd "%~dp0"
        set Countera=0
        for %%a in (*.exclude) do (
            rem increment the counter, so we know how many files we have read.
            set /A Countera=!Countera!+1
            if %Debug% == 1 echo DEBUG - Exclude file found: "%%~na"
            if %%a == %%f.exclude set SkipThis=1
            if !SkipThis! == 1 if %Debug% == 1 echo DEBUG - Skipping Backup of "%%f"
            )
        If %Debug% == 1 echo DEBUG - !Countera! exclude files checked
    popd

    if !SkipThis! == 0 %mysqldump% --host="localhost" --user=%dbUser% --password=%dbPassword% --single-transaction --add-drop-table --databases %%f > %backupDir%\%dirName%\%%f.sql
    if !SkipThis! == 0 %zip% a -tzip %backupDir%\%dirName%\%fileSuffix%_%%f.sql.zip %backupDir%\%dirName%\%%f.sql
    if !SkipThis! == 0 set /A Counterb=!Counterb!+1

    :: make sure to set this back to normal, so we don't skip the next DB backup as well
    set SkipThis=0
)
echo DONE - !Counterf! DBs found, !Counterb! DBs backed up

We then just need to create some blank files with “.exclude” extension. The “.exclude” files have the same name as the DB to exclude. Example such as “sys.exclude” will exclude the “sys” DB from backups

Licensing is as usual, this script is Open Source and we provide a download for your easy of use.

Troubleshooting

  1. If backups are not created, check all your location variables are set correctly

How to Use

  1. Download the MySQL Backup Script and extract into a suitable location.
  2. Open up “MySQLBackup.bat” in notepad++ (or similar).
  3. You will need to change the dbUser, dbPassword, backupDir, mysqldump, mysqlDataDir and zip file/app locations on lines 4-9.
  4. Save the file and run (you can open a command prompt by typing cmd into the title bar of explorer)
  5. This script will now be executable. Go to your command prompt and run this to backup your databases.
  6. If backups are not created, check all your location variables are set correctly

Next time you need to Backup MySQL on windows 10 for free, use this script to make it easy

YTS Backup Script

Download YTS Backup Script

YTS_Backup_script.cmd is an easily customisable backup script for Windows

Through the use of .backup files, its easy to add extra directories or files to backup when run.

To setup, we need to extract the files from the ZIP into a directory.
once extracted, edit “YTS_Backup_script.cmd” file with Notepad++ or similar.

You will then need to setup your script location & backup directory location.

  • 1) Look for “set ScriptDir=D:\files\Projects\YTS_Backup_Scripts” and change it to suite your needs.
    NOTE: This Directory name needs to not have any spaces in it, or the script will fail.
  • 2) Look for “set ScriptDrive=D:” and change it to suite your needs.
  • 3) Look for “set BackupDir=C:\Backups\Manual” and change it to suite your needs.
  • 4) Look for “set BackupDrive=C:” and change it to suite your needs.
  • 5) Open “mydocs.bac” with notepad++ by double clicking on the file, and associating with notepad++.
    Edit this File to your needs. the file contains only two lines.
    Line1 is the source file or directory for xcopy to use.
    Line2 is the destination file or directory for xcopy to use.
    NOTE: do not add extra lines to this file, as this will break the script. two lines only.
  • 6) Open “Outlook.bac” with notepad++
    Edit this File to your needs.
    to add more files to your backup, simply change add another .bac file to the script directory and enter the details correctly.

Download YTS_Backup_script

PC Beacon

PC Beacon flashes the screen and speaks “Attention Required” from the speakers of the computer (using . It was made for use on customers sites where you are remotely controlling a computer, and either require the users attention again, or need someone to find the appropriate PC quickly and easily.

Download PC Beacon

This is achieved, through changing the background colour of a full-screen window (with no borders). The colour change rate is easily changeable (set for once per second as standard).

As normal, this application is written in AutoIt Scripting Language, and has the source code included as a resource of the application.

Minor modifications would be needed to allow setting of all variables from an INI, as the whole script is contained within one function (to allow easy importing into existing projects)

Application is licensed under GPL 3 or later.