Don’t rely on hosting providers’ backups
andymilk | December 1, 2008Most hosting providers backup their servers on a daily basis with an off-site backup once a week. If something catastrophic happens to your server, code, or data, you can rewind to the time of the backup. The problem is that the process for getting the disc or database image back up and running can sometimes take hours or even days.
I learned recently on a project that you should always add your own programmatic way of backing up and restoring a database.
On one specific Rails project, it was as easy as writing an 11 line rake task that performed a quick backup of the mySQL database. A cron job runs this task once a day. If you have enough disk space, feel free to run the backup more often. Twice a day, every hour, etc. You could also write another periodic task that clears out old versions of the backups, in case disk space is at a premium.
Restoring the database is as easy as running one command. I use GZip to extract the data straight into mySQL.
Often times in the rush to finish a project, only the essential functionality and user testing is attended to. Don’t forget about your data loss and recovery plan. Take a few extra hours to build one.
Andy Milk is a web software designer, developer, and consultant located in the Boston, MA area. This site showcases his portfolio and approach to design and development. 




