How To Update Ghost AMI


To upgrade your AMI to Ghost 0.4, check out this article for an automated script to do it for you - http://www.allaboutghost.com/how-to-update-ghost-to-version-0-4/#Update-Amazon-AMI

As Ghost comes out with new releases and we introduce new features to our AMI we will be creating updates Amazon AMIs (release notes for our Amazon AMIs and you will be able to launch new instances to take advantage of them. This article will detail how to preserve the content in your Ghost blog and migrate it over to a new, undated Amazon AMI.

  1. Go to your_site.com/ghost/debug and click on "Export". This will not export your images, but will export all yours posts just in case something goes wrong during this upgrade.

  2. Log into AWS account

  3. On the left hand side click on "Volumes". Click "Create Volume" and create a new EBS volume of 10GB making sure it is in the same availability zone as your ec2 instance. You can look at the already created EBS volume which is the operating system for your EC2 instance to know which availability zone to create it in.

Update Amazon AMI - Create EBS Volume

Update Amazon AMI - Volume Size and Zone
4. ssh into EC2 instance and run this command to see what volume is already attached:

cat /proc/partitions

That outputs the following for me so xvda1 is my operating systems volume:

[ec2-user@ip-172-31-9-21 ~]$ cat /proc/partitions 
major minor  #blocks  name

202        1    8388608 xvda1   
  1. Back in AWS right click on your new EBS volume and click attach

Update Amazon AMI - Attache EBS Volume
Select the EC2 instance that is running Ghost

Update Amazon AMI - Attache Volume to EC2 Instance
6. Now back in your ssh connection run this command again:

cat /proc/partitions 

That outputs the following for me so xvdf is my new EBS volume:

[ec2-user@ip-172-31-9-21 ~]$ cat /proc/partitions 
major minor  #blocks  name

202        1    8388608 xvda1
202       80    1048576 xvdf    
  1. Your new EBS volume is mounted but the volume needs to be partitioned and formatted. To format and partition run this command (replacing xvdf with the volume from the previous step):
sudo mkfs.ext3 /dev/xvdf
  1. Now to mount the EBS
 sudo mkdir /media/storage
 sudo mount /dev/xvdf /media/storage/
  1. Now that our storage is ready we need to stop Ghost and move the Ghost data to our temporary storage.
NOTE: If you are using one of our newer AMIs you will stop Ghost with pm2: pm2 stop ghost
 sudo forever stopall
 cd /var/www/ghost
 sudo cp -r content/ /media/storage 

The Ghost content directory contains your database, images, plugins, and themes. Once the updated AMI is launched we will move that directory over to /var/www/ghost/ and all of your data will be preserved.


10. Now you can shutdown the EC2 instance you are currently logged into down:

 sudo shutdown -h now
  1. Back in AWS go to Volumes and rick click on your new EBS volume and detach it from your EC2 instance.

With your EC2 instance shutdown you will now need to launch a new instance of our newer AMI. If you are unfamiliar with this process you can follow the instruction in our article.

Note: You will get a new public DNS address from Amazon when starting you new AMI. If you are pointing a domain name at the DNS address that Amazon has provided be sure to update the DNS records after your new instance has launched.



12. Once your new instance is up and running ssh into it. Then run the following command to find the operating system volume:

  cat /proc/partitions
  1. Now go into your AWS account, in the Volumes section, and right click on your EBS Volume and click detach, and then click attach. If you only have one EC2 instance it will be the only option to select.
  2. Run this command again to get new EBS volume name:
  cat /proc/partitions
  1. Next in your ssh connection you need to mount and transfer your Ghost data:
NOTE: If you are using one of our newer AMIs you will stop Ghost with pm2: pm2 stop ghost and start Ghost by restarting the server: sudo shutdown -r now

. sudo forever stopall sudo mkdir /media/storage sudo mount /dev/xvdf /media/storage/ sudo rm -r /var/www/ghost/content sudo cp -r /media/storage/content/ /var/www/ghost/ sudo sh /usr/local/scripts/ghoststart.sh Your EC2 instance is now fully up to date from our AMI and your Ghost data is moved back into place, and Ghost is running.


16. IMPORTANT: Check to make sure that all your data is there, blog posts, images, etc. If it is, you can safely terminate your old EC2 instance. If it is not, do not terminate the old instance until you figure out why so you do not lose all your data.

If you need help with the upgrade process just leave us a comment below and we will help you out.

For details on what changes in our Ghost AMI checkout our release notes.