Start the year of right – set up a backup system! A few years ago, I documented how to backup your web sites, databases, email, etc when your host uses CPanel to a remote FTP server. Since then, there have been several CPanel updates and Perl updates that the script no longer works so I have been looking for another option and finally found it. The new script is called: CPsafe (if that does not work, check out the cached version. Within 5 minutes, you can have your home directory backup set up and ready to run. I think the hardest part of this process was figuring out where to turn on FTP access in my Mac OS X 10.5 new install. (System Prefs > Sharing > File Sharing > Options > FTP)
What got me up early Saturday and then up at 1am on Sunday? Server hardware failure…which led to some database corruption. I have never had to deal with database corruption, so I did not even know my problem was database corruption until after calling the helpful tech guys at Liquid Web. (I am not one to usually call tech support, but at 136am on a Sunday…I did not feel like spending time at mysql.com or google.com.)
I first noticed something on Saturday morning, but after restoring a database table from a backup, everything was golden. I told myself…it had to have been from some user error. Monday morning, after my Nagios server paged me, I noticed that jappler.com had several mysql
fetch_row () errors after the server came back up. I decided that this problem was not user error and something else was going on. As soon as I told the tech guy the error that I was seeing onjappler.com and other web sites I manage, he asked me if I had tried “repairing” the databases. I had not even thought about it (especially so early in the morning). Once he “repaired the databases”, everything was perfect.
This was a stressful lesson to learn, but I am always happy to learn new things. The lesson I learned was about database corruption. (All my tables are MyISAM)
[tags]MySQL, database corruption, CPANEL, MyISAM[/tags]
For months I have been manually backing up my web sites. Last night, I learned my lesson and realized I needed to have something more dependable in place. (and I am pretty damn dependable). I finally took the time to research the process of automating a CPanel update.
The script I found and used is freely available and easy to use.
How to completely automate your CPanel backup and store the files remotely:
There are three main parts to this process:
- The backup script.
- Download the script.
- Edit the script’s configuration variables as needed (see instructions on the download script page (see above).
- Set up a cron job via CPanel (cron jobs is one of the main icons in the list) so your script will run every x minutes/hours/days/weeks/months.
- The files you want backed up on your host. The script will have CPanel perform a full backup of all your files and databases. (The same if you were to choose “full backup” within the Backup module of CPanel.)
- The location where your files go when they are automatically backed up.
- Define the server/computer you want your files to get backed up to. If you are like me and do not have a static IP address for the computer you want all your backups to go to (my home computer), you will need to set up Dynamic DNS. (See my HOWTO access your home computers from anywhere post.)
- Set up FTP access to your server/computer (in my case my home computer) so the script can grab the backup and transfer it to your server/computer.
That is all you will need to do. You will be emailed every time this process runs so you will always know when your last backup was/if it was successful. Depending on how many active changes you are making to your web site, you will want to adjust the frequency of the backup. For a web site like this, I will back it up every 7 days. Why five? When thinking about backup strategies, I always think: how many days of work can I afford to lose? Figuring I have a new post every weekday, I can live with a week’s work lost. If I do a code change, a WP update, or a massive posting that I do not want to lose, I will do a manual backup to supplement my backups.
Another recommendation…always keep the latest copy of the backup on the server (your web host) as well as on your home server/computer. This way, you are ok if something were to happen to your home machine or your web host. (I like to have archived copies always available)