Created
November 15, 2014 11:19
-
-
Save motatoes/ff303b094e7279a0a6b2 to your computer and use it in GitHub Desktop.
Self hosted ghost install automated backup script (based on http://www.allaboutghost.com/how-to-automate-backing-up-ghost/)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
GHOST_DATABASE=/var/www/ghost/content/data/ghost.db | |
BACKUP_DIR=/home/ghost/backup/allghostthemes/ | |
BACKUP_RETENTION_PERIOD=10 | |
LOG_FILE=/var/log/backup-allghostthemes.log | |
DATE=`date '+%Y/%m/%Y-%m-%d-%H-%S'` | |
# Make backup directory | |
mkdir -p $BACKUP_DIR$DATE | |
# Stop Ghost | |
service ghost stop | |
echo "Ghost has been stopped - $DATE" >> $LOG_FILE | |
# Copy Ghost Database | |
cp $GHOST_DATABASE $BACKUP_DIR$DATE | |
echo "Ghost has been copied - $DATE" >> $LOG_FILE | |
# Start Ghost | |
cd /var/www/ghost/ | |
service ghost start | |
echo "Ghost has been started - $DATE" >> $LOG_FILE | |
# Prune backup directory | |
find "$BACKUP_DIR" -type f -mtime $BACKUP_RETENTION_PERIOD -iname '*.db' -delete | |
find "$BACKUP_DIR" -type d -mtime +$BACKUP_RETENTION_PERIOD -delete | |
echo "Backup directory pruned - $DATE" >> $LOG_FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment