ghost-backup

Backup ghost blog data.

This does two things:

  1. Download the JSON export of the ghost post database

  2. Make a copy of the ghost content directory (image assets, etc.)

Part 2 is only run

Install

gem install ghost-backup

Usage

Config

The first step is to generate ghost-backup.yml:

$> ghost-backup config
Writing config to ghost-backup.yml

The edit this file:

---
username: 
backup_dir: ghost-backup/%Y-%m-%d-%H%M%S
ghost_dir: /var/www/ghost
refresh_token: 
base_url: https://localhost

Login

Once you have your ghost-backup.yml, you can login to ghost:

$> ghost-backup login
Logging in to https://my.blog/ghost/api/v0.1/authentication/token
Need username, password to generate new token (only used once, not stored).
Username: |you@email.com| 
Password (not stored): *****
Writing config to ghost-backup.yml

Ghost tokens expire after a week, so to keep them alive you have to login at least once a week:

$> ghost-backup login
Logging in to https://my.blog/ghost/api/v0.1/authentication/token

Unless your token expires, logins after the first will not require a username or password.

Backup

Now you can run a backup:

$> ghost-backup
Backing up 'https://my.blog' to '/backup/ghost-backup-2015-09-15-1306'
Copying /var/www/ghost/content → /backup/ghost-backup-2015-09-15-1306/content
Downloading ghost database https://blog.jupyter.org/ghost/api/v0.1/db/
Backing up database to '/backup/ghost-backup-2015-09-15-1306/ghost-db.json'