This Windows Service automatically backs up a MySQL database at regular intervals. It’s designed to be easy to install and configure for new users.
- Scheduled automatic MySQL database backups.
- Logs events for monitoring.
- Configurable backup intervals and target directories.
- Windows Operating System
- MySQL Database Server
- Ensure the
mysqldump
tool is installed and added to your PATH environment variable.
- Ensure the
- .NET Framework
- Version 4.0 or later (required for
InstallUtil.exe
).
- Version 4.0 or later (required for
- Clone the repository or download the latest release from the Releases page.
- Ensure the following files are in the same directory:
InstallService.ps1
(PowerShell installation script)Setup.exe
(the Windows Service executable)
- Open the service's configuration file (
app.config
or.env
) if applicable. - Update the following fields:
- MySQL Connection Details:
DB_HOST=localhost DB_USER=root DB_PASSWORD=yourpassword DB_NAME=yourdatabase
- Backup Directory: Specify where backups will be saved.
- Backup Interval (if configurable): Adjust the interval for automatic backups.
- MySQL Connection Details:
-
Run the PowerShell Installation Script: Open PowerShell as Administrator, navigate to the folder containing the files, and run:
powershell -ExecutionPolicy Bypass -File InstallService.ps1
This script will: Request admin privileges. Verify that the necessary tools (InstallUtil.exe) are available. Register the service with Windows.
Verify Installation: Open the Services Manager (services.msc) and look for MySQL Backup Service. Ensure the service is set to Automatic start type.
Step 4: Start the Service
Open Services Manager (services.msc).
Find MySQL Backup Service in the list.
Right-click the service and select Start.
Stop the service:
Stop-Service -Name "YourServiceName"
Start-Service -Name "YourServiceName"
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe" /u Setup.exe
Ensure you ran the script with administrator privileges.
Check that InstallUtil.exe is available on your system.
Verify that the mysqldump command works manually.
Check the configuration file for correct MySQL credentials.
Check the service log files in the specified log directory for error details.
Contributions are welcome! If you encounter any issues or have suggestions for improvement, please open an issue or submit a pull request.