Whether on Linux or Windows, it’s imperative that MySQL databases be regularly backed up to prevent data loss. And any data loss is much more likely to be from human error than a system failure. But the installers for MySQL and MariaDB do not touch on database backups beyond installing the mysqldump utility. Information to be found for backing up MySQL databases pertains mostly to Linux, and the plethora of backup scripts available for Linux are generally not suitable on Windows.
To fill this gap, I created the PS-BackupMySQL package. It provides the PowerShell script Backup-MySqlDatabases to back up all user databases and the mysql system database. (Other system databases are dynamically created and do not need to be backed up.) It’s designed to be run interactively or from a Windows scheduled task to back up databases on a regular schedule. And since databases that are backed up may eventually need to be restored, the script Restore-MySqlDatabases is provided to restore databases – one, many, or all – from the backup files. Also included are Create-MySqlBackupUser which simplifies creating a backup user with only those privileges needed to back up the databases and Create-MySqlBackupTask to create a Windows scheduled task to back up the databases.


