A simple batch script to automate MySQL backups on XAMPP (Windows), upload them to AWS S3
Before using this script, ensure:
- XAMPP is ofcourse installed (
C:\xamppor modify the path in the script). - AWS CLI is installed and configured with credentials (
aws configure). - You have an S3 bucket and Access Key ready for uploads.
-
Clone the repository:
git clone hhttps://github.com/MufaroDKaseke/mysql-s3-backup.git cd mysql-s3-backup -
Install AWS CLI (if not already installed):
Download AWS CLIaws --version > aws-cli/2.24.15 Python/3.12.9 Windows/11 exe/AMD64 -
Configure AWS CLI with your credentials:
aws configure
This will prompt you for:
- AWS Access Key ID
- AWS Secret Access Key
- Default region name (e.g.,
af-south-1) - Default output format (e.g.,
json)
-
Edit the script and set your S3 bucket name:
set s3_bucket=s3://<your-bucket-name>/mysql-backups/
-
Run the script:
mysql_backup.bat
The script will:
- Check if MySQL is running on port 3306
- Create a backup directory if it doesn't exist
- Create a timestamped backup of all MySQL databases
- Upload the backup to your specified S3 bucket
-
Check if it worked:
aws s3 ls s3://<your-bucket-name>/mysql-backups/
Or just check the bucket in AWS Console:
You should see your backup files listed with today's timestamp.
Let me know if you need further modifications! 🚀