Best way to backup ghost self hosted


Hey fine folks.

I am looking to move away from Wordpress to a ghost based blog. As the blog will be self hosted, backups are of utmost importance to me. After scouring the forum, I do not see an easy way to backup from within the admin UI.

I see that I can export a JSON file, but what about the content (images, etc)?


There’s no wasy way to do a Ghost backup unless you go the linux bash scripting way.

You could create a cron job to do the following:

cd /path/to/ghost/
tar cvfz ghost-site/ ghost-site.tar.gz
cp -Rv /path/to/ghost/archive.tar.gz /backup/location/
mysqldump -u user -p mysqlserver (localhost) ghost_db > ghost_db.sql
mysqldump -u user -p -h mysqlserver (remote) ghost_db > ghost_db.sql
cp -Rv ghost_db.sql /backup/location/

You can put the above into a script so you only run a single cron job instead of several.

I assume there are other ways to backup a Ghost blog, but this would automate things at least.

For multiple ghost sites you could try any one of the below scripts:

#Archive all folders in individual .tar.gz files:
for dir in `ls`; do tar -cvzf ${dir}.tar.gz ${dir}; done


for dir in *; do [ -d $dir ] && tar -zcf /tmp/archive/$dir.tar.gz $dir/; done

DB backup:

Export all mysql databases in individual files:


databases=`mysql -u $USER -p$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`

for db in $databases; do
    if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != "mysql" ]] && [[ "$db" != _* ]] ; then
        echo "Dumping database: $db"
        mysqldump -u $USER -p$PASSWORD --databases $db > `date +%Y%m%d`.$db.sql
       # gzip $OUTPUT/`date +%Y%m%d`.$db.sql
Backup best practices
closed #3

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.