Automatic backup

By the way, this was the post (from Ghost staff) where I found that import/export was the good way to go:

Is this the right way to backup the DB?

#!/bin/bash

GHOST_DIR=/opt/ghost
GHOST_CONFIG=config.production.json

GHOST_BACKUP_DIR=~/

ghost_db=$(jq -r '.database.connection.database' ${GHOST_DIR}/${GHOST_CONFIG}) 
ghost_user=$(jq -r '.database.connection.user' ${GHOST_DIR}/${GHOST_CONFIG})
ghost_pwd=$(jq -r '.database.connection.password' ${GHOST_DIR}/${GHOST_CONFIG})

mysqldump --user=${ghost_user} --password=${ghost_pwd} --databases ${ghost_db} --single-transaction  --no-tablespaces | gzip > ${GHOST_BACKUP_DIR}/ghost_db_`date +%Y_%m_%d_%H%M`.sql.gz
1 Like