Archive for April 9th, 2008

Backing up my WordPress Blog on my Mac

Long time readers will know that I just started this blog.

Since I installed this on my Mac Mini, I decided I needed a way to back up the SQL data. If this Mac fails, this blog is toast. Most of what follows applies to any Linux machine.

I wrote a pretty simple script to run the backup. If you want to do something similar, use Terminal on the host Mac (or you can login remotely, but that’s another story). Go to a directory where you keep scripts (maybe “/usr/sbin” - you can do that by typing cd /usr/sbin).

Then create a file named something like blogbackup.sh (to do that, type vi blogbackup.sh).

Then, since you’re in the editor vi, you’ll need to press “a” then paste the following, replacing password with your SQL password, and backup with your secondary hard drive (or replacing /Volumes/backup with a different location on your primary drive, but that defeats half the purpose . . .).

 #!/bin/sh
mysqldump --add-drop-table -ppassword wordpress | bzip2 -c > blog.bak.sql.bz2
cp blog.bak.sql.bz2 /Volumes/backup/blog.bak.sql.bz2

To save in vi, press ESC then :w then :q.

Set the permissions to be sure this will execute:

chmod 777 blogbackup.sh

chmod +x blogbackup.sh

(I confess to not being a chmod expert, so those commands might be overlapping.)

To test out the script, type: 

 ./blogbackup.sh

From there, you should set up a recurring crontab to take care of the job. I set mine up as the superuser so that it would run without interruption. To do that, you’ll need root access - that’s a whole different story. But once you have it, here’s what you do:

crontab -e

brings up the list of cron jobs. To add a new one, paste in a line like this:

10 2 * * * /usr/sbin/blogbackup.sh

That basically says at 2:10 AM, run that script everyday. Save and quit with :w then :q.

Amazing, but true. An inexperienced ticket buyer like myself was able to wade through the morass of the Radiohead pre-sale, and actually get some tickets. Funny enough, a message popped up on the Radiohead message board saying that all California shows were confirmed sold out, and just then my browser page completed allowing me to add four tickets to my cart.

It took a while, and it was a bit of a nail-biter, but I was able to get the sale completed. I even went so far as to correctly answer the question about my birthday (are they planning something for me?) just to be sure I wouldn’t get bumped.

I’m glad to know that WASTE isn’t letting Ticketmaster beat them out on the shipping and handling charges. They have some steep fees of their own. But it looks like I ended up with P1 seats, which I think were the best available during the presale.