Last active
September 5, 2016 16:55
-
-
Save urlicht/ec68dcba2e22520c6de553e2c5ebc650 to your computer and use it in GitHub Desktop.
Bash script to locally backup (copy and tar) 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 | |
########## Change variables ########## | |
BACKUP_LOC='/home/spooky/ghost_backup/' # where to store backup | |
GHOST_LOC='/var/www/ghost/' # where Ghost lives | |
###################################### | |
echo $(date)': backup ghost script begin' | |
# create backup folder | |
dateStr=$(date +%Y-%m-%d-%H%M) | |
dirName=$dateStr'_ghost_backup' | |
dirPath=$BACKUP_LOC$dirName'/' | |
mkdir $dirPath | |
# stop ghost service | |
cd $GHOST_LOC | |
forever stop index.js | |
# copy files | |
cp -r $GHOST_LOC $dirPath | |
# start the service again | |
cd $GHOST_LOC | |
NODE_ENV=production forever start index.js | |
# tar files | |
cd $BACKUP_LOC | |
tar -zcf $dirName'.tar.gz' $dirName'/' | |
# remove copied directory | |
rm -r $dirPath | |
echo $(date)': backup ghost script end' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment