# Updating Ghost

I will admit, I have not been very good about keeping Ghost up to date. Back in October I received an email about the big October update, I believe this was 0.5.3. I just updated to the now current version (0.5.6). I have to look up the process each time I update, so I figure I’ll write about it, that way I’ll have a solid footing when I update to 0.5.7, perhaps motivating me to keep things up to date.

# Finding Support

I love Ghost as a blogging platform. I can run my own installation of it and writing posts in it is easy. (Not to mention it looks great.) I, however, find looking for information on their site a less intuitive experience. There is something strange to me about the layout, for instance, I know they have a forum, but there is no link on the main page for it, instead it is under support.

Anyway, my usual approach is to just turn to Google, but Google often turns up results from http://www.howtoinstallghost.com, which I’m not sure is actually affiliated with the Ghost team. While I like their goal of providing easy to use instructions for those looking to just use the platform without any of the technical details, it lacks some of potentially crucial info, such as this note about backing up your blog’s data before performing an upgrade on the actual Ghost support page:

Note: You can, if you like, take a copy of your database from content/data but be warned you should not do this whilst Ghost is running. Please stop it first.

I actually ended up doing this while Ghost was still running, thinking it was a great idea, before I found that page. My data survived, but next time I might not be so lucky.

That being said, the first thing we should is back up our precious data.

# Backups

As noted here, to backup all we have to do is export a .json file from the administrative interface of Ghost. This previously was found under /ghost/debug/, but now is located under /ghost/settings/labs/. Simply click export and you are all set!

Something I’d like to see in a future release (heck it might exist now), is a way to automate this. I’d like to just have a cronjob setup to backup my blog every week (day, hour, minute, whatever, depending on how often you write new content - not often if you’re me - and how paranoid you are).

The last thing to backup is themes. Casper is the default theme, and lives in your ghost directory under /content/themes/. They’ve been updating Casper fairly frequently. And they suggest just getting rid of the old versions and installing the latest. I’ve modified the first version I used though, and the design influenced other parts of my website, so I like to keep old versions. If you simply move /content/themes/casper/ to something like /content/themes/casper_0.5.2/ then you’ll see the previous versions when you go to change your themes in the admin panel.

Now that we’ve backed up our data let’s get to the actual upgrade, shall we?

• We’ll need to download the latest release, which I find most convenient to get from their github.
• I usually make a tmp directory in /var/www/ghost/, where I have ghost installed, and extract this .zip file there.

• Next, in /var/www/ghost/ we’ll delete index.js, and package.json, then copy the new ones in.

• We’ll do the same with core/.
• Then we’ll copy over the new Casper version.

You’ll want to replace the 0.0.0 with a version number most likely. You can also just delete the old version if you’d like.

• Finally, we need to run sudo npm install --production. This will take a few minutes, go grab some coffee.

# Testing and Running with forever

When it’s done I like to test things out with a sudo npm start --production. This will start Ghost. To keep ghost running I had initially used forever. If you don’t have forever installed, run npm install -g forever within your ghost directory. I like to then start Ghost with forever with the following options.

The NODE_ENV definition should be changed to suite your needs, but I’m running the production environment. If you too are in an environment that isn’t the development one, and you forget this bit, you’ll probably panic when you see your blog come up empty. It startled me a bit until I realized my error. Finally, the -l /var/www/ghost/forever.log logs the output, which is always useful.

# Wrapping Up

We’ve successfully upgraded Ghost! If everything went smoothly you’ll be on the latest version. So quit reading this and go write a new post! Before you do though, let me just remind you to clean up a bit, mostly just get rid of that ./tmp/ directory.

Happy ghosting!

Updated: