What does the PG&E induced craigslist outage have to do with your church or charity website? How about a reminder of the tired but true adage that reads ‘Those who fail to plan, plan to fail.’ Specifically using mysqldump, crontab and perhaps ftp or rsync to insure you’re data isn’t dead in the water when your host goes down.
- One of the big advantages of running a web services company out of the San Francisco area is that you’re located where the majority of action is – at least in the U.S.
- One of the big disadvantages of running a web services company out of the San Francisco area is that when the Bay area takes a power hit – you’re down with the best of them.
This power-packed paragraph from the Boston Herald exemplifies the scope of the situation:
AT&T Park, home of the Giants, was also affected hours before a scheduled night game. Six Apart Inc., a blog-hosting service, said its sites began failing shortly before 2 p.m., and the company sent an e-mail to customers blaming the cityâ€™s â€œpower issues.â€ Several other Internet sites with San Francisco offices had problems, including Craigslist, Technorati, Yelp, Red Envelope and CNet. It was unclear whether the problems were related to the outage.
Now while I suspect the ‘big guys’ have contingency plans to quickly relocate had this been a long-term failure, I also speculate that your church and/or charity’s emergency plans may not be so robust as to handle something such as a hosting provider that goes belly-up due to either natural and/or financial disasters.
That said, there are some no-cost, low-bandwidth solutions are already available to those of you opting to manage your site’s content on a LAMP platform using an application such as WordPress or Drupal.
Here’s all you need to cook-up your own recipe for success:
- putty for shell access to your website/host
- access to the mysqldump command
- optional access to the gzip command
- your database username
- your database password
- your database server name
- optional access to the crontab utility
So if nothing else, with the above you could set up a nightly job that backs up and then gzips your database all in one fell swoop:
$ mysqldump -uMYSQLUSERNAME -h localhost -pMYSQLPASSWD wp_MYDB | gzip -9 > wp_MYDB-db.sql.gz
This approach is of course not without its downside, specifically:
- you could be potentially overwriting a good backup with a corrupted data backup
- you still have your backup on a server that could go down
- you have no real report as to the validity of the backup
Instead, it’s probably advisable to create a script and/or perhaps write a PERL program to enhance this process to:
- first grandfather the last good archive backup
- then archive the last good backup
- then add a date stamp to the file
- then make a copy of a successful backup to another location
- finally, email you and/or log the results
But who as time to write a script you ask? Well, fear not, one of the reasons I’ve filed this article under ‘resource filled’ is because I found a wonderful little service entitled: the FTP backup script generator.
You simply enter the parameters, it generates a script that you then copy and paste onto your system – then crontab to run on a nightly basis.
And if that doesn’t float your boat, here are a few other articles on the topic of how to use crontab, MySql and FTP or rSync to keep your data safe and sound now matter how badly the power fluctuates about your backup-savvy server.
- NixCraft – How to backup MySQL databases, web server files to a FTP server automatically
- How to have automatic backups of your mySQL database – ThemeBot
- How To Forge: Create Incremental Snapshot-style Backups With rSync And SSH
- MySQL backups using mysqldump by CrazyToon
- Peter’s Blog: rSync articles by tag
- Automated Backups on Tiger Using rsync – O’Reilly MacDev Center
- VoorBurg: Backup script for Linux using tar and find
- How to backup your MySQL tables and data every night using a bash script and cron – CGI Interactive
- Old Guy’s Scripts: MySqlDump database backup script
I know we’re all busy, and I said, this approach is a mere pittance in light of true disaster recovery. That said, it is up to make sure you have at least taken the above precautions â€¦ and from there add more points and detail â€¦ for as it is written (with apologies to the inspirational text of Romans 10):
How can they restore the data without knowing how?
And how can they know how without having practiced?
And how can they practice without someone teaching them?
And how can someone teach without documentation?
As it is written, â€œHow beautiful are the webmasters who have planned ahead!â€