How to Setup an Automated Full Backup of Your Ghost Blog onto an Amazon S3 Bucket
Mar. 20, 2020 · 1 min read
Ghost offers a quick way to backup your settings, users, subscribers, posts, pages and tags using the export settings in your dashboard. Everything will be downloaded into a single JSON file. However, this export won't include your theme files, images or original database.
For a full backup of your complete Ghost blog and setup, that includes your theme files, images, content and database, you'll need to put a backup script together. Here's are the steps to backup everything onto a Amazon S3 bucket in the cloud:
Copy your entire Ghost contents directory
cp -ar /var/www/ghost/content
Optional: remove the log files to save space
rm -r /var/www/ghost/backup/logs
Compress your content using Tar
tar -czf /var/www/ghost/ghost-backup.tar.gz /var/www/ghost/backup
Backup your Ghost database
sqlite3 ".backup '/var/www/ghost/content/data/ghost-local.db /var/www/ghost/backup/ghost-local.db'"
Copy the backup Ghost files to your Amazon S3 Bucket
aws s3 cp --no-progress /var/www/ghost/ghost-backup.tar.gz s3://yourbucketname/ghost-backup.tar.gz
aws s3 cp --no-progress /var/www/ghost/backup/ghost-local.db s3://yourbucketname/ghost-local.db
Save each of these commands to a bash script, and set a cron to run nightly. You've now backed up your entire Ghost blog including all contents and database. You'll have a local copy on your server, and also a second copy on your Amazon S3 bucket. Safe, and secure!
Sign up for our newsletter
Your email will be used to send you our new blog posts and updates. You can unsubscribe at any time using the link in our emails.