Backing up my VPS: Settings, websites and MySQL
I’ve seen the painful lessons many times: lazy website owners thinking their webhost would last forever, and neglecting to save their own backups. But really, you learn a lesson the best when you actually feel the pain. And I sure did.
To prevent this, I decided to automatically, and regularly backup my VPS and store them on my computer. I searched Google a bit, and found two typical approaches: a simple shell script, or a full-fledged backup solution. I decided that I didn’t need something like Amanda or Bacula. I didn’t feel too inclined to messing with scripts though. However, I found this nifty tutorial to backup web server files and MySQL databases. The tutorial came complete with a script generator, which was really handy.
I made some changes to the generated script though:
- I prefer the yyyy-mm-dd date format for easier (and natural) file name sorting. I also changed the timestamp of the MySQL dumps to match the file dump timestamp format.
- Because I’m not running large websites, I decided to change the script so that the full backup is only run once a month instead of once a week, to save on resources.
With this script running, I should not have to encounter another situation where I lose months of data. Well, unless the backups stop running without me realising.