Time
March 14, 2019, 3:17pm
1
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 backup.sh 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
or
for dir in *; do [ -d $dir ] && tar -zcf /tmp/archive/$dir.tar.gz $dir/; done
DB backup:
Export all mysql databases in individual files:
#!/bin/bash
USER="root"
PASSWORD=""
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
fi
done
3 Likes
system
Closed
March 29, 2019, 1:00pm
3
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.