Backup Your DBs!!

December 11th, 2004

Today I was upgrading to the latest MySQL version and in so doing I went and deleted the old install. Thats all normal apart from when you forget to copy the data directory over, and thus losing everything since the last backup I did 3 weeks ago. Now I suppose you could specify your data directory to be outside of the installation directory but still, you have to back it up.

Basically what I’ve done is the following; made a batch file which stops the mysql service, add the data directory to a rar file named to the current date (using WinRAR‘s command line executable) and then restarting the mysql service. Once having done this, I set windows scheduler to run this script once a day.

Hope this is usefull!

mysql-backup.bat:
@echo.
cd backup
net stop mysql
"C:\Program Files\WinRAR\Rar.exe" a -r -agYYYYmmdd MySQL-.rar ..\mysql-4.1.7-win\data*
net start mysql
cd ..
@echo.


Leave a Reply