This post will cover how to easily backup your MySQL Database.
I typically use this script to backup my Databases. Rename the file to backup.bat
- Lines 3&4 get the date and time. This time stamp will be added to the database backup files.
- Line 7 sets up the variable bkupfilename that will be using
- Line 11 – Enter your password in between the quotes. The first time I used a really complex password there were some incompatible characters with the command line.
- Line 16 – Deletes any file in the mysqldump folder that is older than 3 days.
Here is what the output looks like:
It’s nice that the password isn’t shown in the output. There were no files older than two 3 days in the folder so it didn’t have any files to delete.
*NOTE* – Do not put the script in the same folder as the database dumps. If you do after 3 days it too will be deleted!