Reference: ghost.org/docs/ghost-cli/#ghost-backup
- Your content in JSON format
- A full member CSV export
- All themes that have been installed including your current active theme
- Images, files, and media (video and audio)
- A copy of
routes.yaml
andredirects.yaml
orredirects.json
- MySQL database
Starting Ghost-CLI version: 1.21.0 they started supporting ghost backup
command. However, the current ghost backup
command does not include a backup of MySQL by default.
wraith
now invokes ghost backup
under the hood.
wraith
was last developed & tested on:
# ghost version
Ghost-CLI version: 1.24.1
Ghost version: 5.52.1 (at /var/www/ghost)
# mysql --version
mysql Ver 8.0.33-0ubuntu0.20.04.2 for Linux on x86_64 ((Ubuntu))
# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.5 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.5 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
- Install
rclone
usingcurl -s https://rclone.org/install.sh | bash
- Run
rclone config
- Name your remote
remote
- Check https://rclone.org//#providers and use the cloud provider of your choice
- If you're working on a remote machine without a browser (e.g. Digital Ocean Droplet via SSH), say
N
for the auto config prompt. Follow through the instructions - Run
rclone lsd remote:/
to check your connection
An example to configure Rclone with Google Drive (reference).
NOTE: If you're getting Error 403:rate_limit_exceeded
error, read this.
Reference: crontab.guru
- Add a
crontab -e
item - For this example, we will back up the data every week:
0 0 * * 0 cd /$HOME/wraith/ && ./backup.sh
In the expect
script, we set the email and password variables to your email address and password, respectively. Then we spawn the ghost backup
command.
The script uses expect to wait for specific patterns in the output. When it sees the pattern "Ghost administrator email address", it sends the email using send. Similarly, when it sees the pattern "Ghost administrator password", it sends the password. The \r is used to simulate pressing the Enter key.
NOTE: Make sure you have the expect package installed on your system before running the script.
"Backups are not backups unless you have tested restoring from them."
Let's test our backup locally using Docker.
- At a new directory, copy your
backup-from-vA.BB.Z-on-YYYY-MM-DD-HH-MM-SS
backup file there. Decompress the backup files usingunzip
- Run Ghost locally using
docker run -d --name some-ghost -e url=http://localhost:3001 -p 3001:2368 -v /path/to/images:/var/lib/ghost/content/images ghost
to restore the blog images - Visit
localhost:3001/ghost
to create an admin account - From the Ghost Admin interface (
localhost:3001/ghost/#/settings/labs
), import your JSON Ghost blog content from decompresseddata/
- You can import your members CSV from the Members page too
Tip: run bash
within your Ghost Docker container using docker exec -it some-ghost bash