Skip to content

Instantly share code, notes, and snippets.

@odarriba
Last active July 17, 2018 08:50
Show Gist options
  • Save odarriba/2db616296a7dcb5cec52 to your computer and use it in GitHub Desktop.
Save odarriba/2db616296a7dcb5cec52 to your computer and use it in GitHub Desktop.
Script to backup a ghost installation to Dropbox

Ghost backup script

This script allows you to automatically archive and upload a backup of your existing Ghost data to your Dropbox account.

How to use it

You'll need to follow this tutorial.

Then, you must create an executable script using the code of ghost_backup.sh in this gist (but modifying your blog's path and prefix).

If you have followed the tutorial and both scripts are on the same folder, you should be able to create your first buck by running bash ghost_backup.sh.

Make it works by its own

If you want to automatize the backups, you only have to put an entry on the crontab and it will work!

#!/bin/bash
GHOST_DIR="/var/www/ghost"
BACKUP_PREFIX="backup"
DATE=`date +%Y%m%d`
DATE_OLD=`date --date="-7days" +%Y%m%d`
tar -zcvf $BACKUP_PREFIX-$DATE.tar.gz $GHOST_DIR/content
./dropbox_uploader.sh upload $BACKUP_PREFIX-$DATE.tar.gz .
./dropbox_uploader.sh delete $BACKUP_PREFIX-$DATE_OLD.tar.gz
rm $BACKUP_PREFIX-$DATE.tar.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment