This is the final article (I think…) on MySQL database backup. In my previous article I discussed how to craft a very efficient script for automated LOCAL backup of your MySQL databases. But that isn’t the whole story. What happens if your server burns to the ground… or more likely the hard drive gives up the ghost, corrupting everything and effectively leaving you up the proverbial creek without a paddle? Today I want to finish our script by adding a couple of extra components and giving you a paddle in the form of “offsite” backups. (more…)

Earlier this year I wrote an article about creating scripts for backing up your MySQL databases.

A week ago I wrote another article about automated and secure root user login to your root MySQL database account.

I have also been learning Python on and off and learning quite a bit about variables and loops. While the syntax doesn’t carry over to BASH, the the logic does.

Combining the ability of password-less root login and for-do loops, I was able to drastically clean up the size of my original database backup script (my first reference above). To be exact, I had nine databases and 35 lines of code. My new script has 10 lines of code. Furthermore, my original script wasn’t “intelligent” in the sense that you would have to update it (and make it longer) anytime you wanted to backup an additional database. The script I am going to discuss in this article should stay at ~10 lines regardless of how many databases are being backed up on the server.

So today’s script is vastly shorter and, better yet, will automatically backup any new database you add to your MySQL instance! Awesome right? (more…)

If you haven’t gotten around to setting up regular backups of your website MySQL databases you are asking for serious trouble. In this article I am going to provide shell script examples that you can use to quickly setup database backup jobs. As far as scope goes, we are going to be talking about how to perform a backup to a local directory, compress that backup file, and then port it off to a remote location if you so desire. The following method has worked really well for me and I hope it does for you as well.
(more…)

This tutorial assumes you have some experience with Linux administration although I try to hand-hold as much as possible. If you are on a shared hosting solution and don’t have root access, you can easily modify the shell script we will create later to target your user’s home directory on the server.

You also need to know the address of your SQL server. In my case, I am working on a VPS so the SQL server is local (so I just use localhost) but you might need to use a URL or IP where your SQL server is located.

Okay… digging in. Here is the gist’ of it…

1. Create a new user for your MySQL database that will be just for backups
2. Create some folders on your server to store your backups locally
3. Create a script to actually create the database backups, compress them, clean up backups older than 30 days
4. Test the script
5. Setup the script to run as a cron job.

Here we go!
(more…)