How to have automatic backups of your mySQL database

The following guide provides a walk-through for setting up automatic backups of your mySQL databases using the AutoMySQLBackup file bash script. After reading the guide, it should be quick and easy to implement. This is an indispensable tool for webmasters. Once the backup system is in place you’ll have daily, weekly and monthly backups of your mySQL databases neatly organized in a private folder on your web server. They are automatically rotated so that they don’t eat up your storage space. Anytime you download a backup of your home directory all of the database backups will be included. This is much better than creating manual backups and can be a huge time saver if you have multiple databases.

Prologue

If you already know why you should be backing up your databases and want to skip ahead to the actual tutorial. Websites based on any type of content management system are pretty much guaranteed to be database driven. It is assumed that most people running their websites on virtual or dedicated servers already have a backup system in place and know how to set this up. If you are reading this tutorial, chances are you are using a shared hosting provider with a LAMP configuration (Linux Apache MySQL PHP). It is also likely that you have CPanel for site administration.

Reasons why automatic database backup is a good idea

Getting a backup system in place may require a little extra time and effort in the beginning, but this can prevent a future catastrophe. If you don’t want to lose all of the hard work you have put into building your website, you need a backup system. Most of the actual content, i.e articles and posts, comments, member data, statistics, settings etc. are stored in the database. It is also important to backup the files related to your site, but the critical backup is the database because that is where most of the content is being added and updated.

What can go wrong?

  • Hardware Failure:Over the past six months I have been through two hardware failures with one of my hosting providers. The first one was due to a hard drive crash. Although my provider has a backup system, after the server was taken back online many of my files were not restored. The only thing that saved the affected websites was having my own local backup. This may have been an unlucky anomaly, but I have first-hand experience why it is important to have regularly updated site backups on my own computer.
  • Hacked Website: No need to get into the semantics of whether a site was “hacked” or “cracked”. If your website was compromised either by somebody who cracked your site or by somebody who gained access through another cracked site on the shared server, there is not way to know exactly how much damage was done. It is necessary to start over with a fresh backup of your site (and if it was your site that got cracked, determine where the security hole was.) This is the great thing about having daily, weekly and monthly backups. If it is a few days or a few weeks before you find out that your site was hacked, you can always go back to the most recent backup that was not affected. This also ties in to the next situation where things can go wrong.
  • The OOPS! Factor: Maybe it is getting late at night, you are working on a website and you accidentally overwrite some important files. Or maybe you decide to install a new module that screws up your database. There are a number of ways to create havoc for yourself. If this occurs and you have been making frequent backups, you can always revert to the last working backup to undo the damage.

The beauty of setting up AutoMySQLBackup is that you can download all of your files and database backups with one click once the setup is complete.

[via themebot.com]

Read the next post “How to install AutoMySQLBackup

Share your love

Leave a Reply

Your email address will not be published. Required fields are marked *