(Note the backticks and enter your MySQL password immediately after the -p option [less the square brackets]. You can find the MySQL password in /var/www/ghost/config.js).

What this Does

We first stop Ghost to ensure nothing changes while we are backing up. To conserve space, we delete all older backups already in the directory. An archive copy of the entire blog (including images) is copied to a separate folder and the MySQL database exported.

The '-a' option is important because it preserves everything about the original copy: most importantly, the permissions. You want the permissions to stay the same or you will have big problems when you go to reinstall from your backup!

Home Backup

I tested this on a Linux workstation.

Anacron is a good choice for Linux workstations that aren't on all the time. Anacron is similar to cron but unlike cron will run missed jobs the next time the computer is turned on.

Make sure SSH keys are set up with your host. SSH into your vps and add the following command to the bottom of /etc/anacrontab:

I am copying the backups made earlier instead of copying the blog directly. This is because my host blocks the ports I need to receive the MySQL dump.

If you want to know what is going on there, I found a cool site called explainshell.com. It explains the different options so you can adjust them to suit your needs.

Bonus Trick

You might not want to set up SSH keys for your root user. If that's the case, in the previous anacron job add sudo -u user just before rsync, replacing 'user' with the user for whom SSH keys are set up.

Restoring from Backup

To restore from backup you will replace the contents of /var/www/ghost/ with the contents of the latest .bak file. i.e.

If you use MySQL, you will have to reinstall the database as well. Before doing that though, I'd see if the current database is working. If it isn't, use the backup sql file you made. Details about how to repopulate your database can be found here.