Backup the database and content subdirectory for ghost

This commit is contained in:
Bob Mottram 2017-07-28 11:17:47 +01:00
parent 14efdb6a2f
commit 388a4c8885
1 changed files with 23 additions and 5 deletions

View File

@ -221,12 +221,12 @@ function backup_local_ghost {
GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain") GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
fi fi
ghost_path=/var/www/${GHOST_DOMAIN_NAME}/htdocs ghost_path=/var/www/${GHOST_DOMAIN_NAME}/htdocs/content
if [ -d $ghost_path ]; then if [ -d $ghost_path ]; then
function_check backup_database_to_usb function_check backup_database_to_usb
backup_database_to_usb ghost backup_database_to_usb ghost
backup_directory_to_usb $ghost_path ghost backup_directory_to_usb $ghost_path ghostcontent
restart_site restart_site
fi fi
} }
@ -245,6 +245,15 @@ function restore_local_ghost {
function_check restore_database function_check restore_database
restore_database ghost ${GHOST_DOMAIN_NAME} restore_database ghost ${GHOST_DOMAIN_NAME}
temp_restore_dir=/root/tempghostcontent
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir ghostcontent
if [ -d $temp_restore_dir ]; then
cp -r $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
chown -R ghost:ghost /var/www/$GHOST_DOMAIN_NAME/htdocs/content
rm -rf $temp_restore_dir
fi
MARIADB_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb) MARIADB_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb)
ghost_config=/var/www/${GHOST_DOMAIN_NAME}/htdocs/config.js ghost_config=/var/www/${GHOST_DOMAIN_NAME}/htdocs/config.js
sed -i "s|password :.*|password : '${MARIADB_PASSWORD}',|g" $ghost_config sed -i "s|password :.*|password : '${MARIADB_PASSWORD}',|g" $ghost_config
@ -278,11 +287,11 @@ function backup_remote_ghost {
GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain") GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
fi fi
temp_backup_dir=/var/www/${GHOST_DOMAIN_NAME}/htdocs temp_backup_dir=/var/www/${GHOST_DOMAIN_NAME}/htdocs/content
if [ -d $temp_backup_dir ]; then if [ -d $temp_backup_dir ]; then
suspend_site ${GHOST_DOMAIN_NAME} suspend_site ${GHOST_DOMAIN_NAME}
backup_database_to_friend ghost backup_database_to_friend ghost
backup_directory_to_friend $temp_backup_dir ghost backup_directory_to_friend $temp_backup_dir ghostcontent
restart_site restart_site
else else
echo $"Ghost domain specified but not found in /var/www/${GHOST_DOMAIN_NAME}" echo $"Ghost domain specified but not found in /var/www/${GHOST_DOMAIN_NAME}"
@ -306,7 +315,16 @@ function restore_remote_ghost {
function_check ghost_create_database function_check ghost_create_database
ghost_create_database ghost_create_database
restore_database_from_friend ghost ${GHOST_DOMAIN_NAME} restore_database_from_friend ghost
temp_restore_dir=/root/tempghostcontent
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir ghostcontent
if [ -d $temp_restore_dir ]; then
cp -r $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
chown -R ghost:ghost /var/www/$GHOST_DOMAIN_NAME/htdocs/content
rm -rf $temp_restore_dir
fi
MARIADB_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb) MARIADB_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb)
ghost_config=/var/www/${GHOST_DOMAIN_NAME}/htdocs/config.js ghost_config=/var/www/${GHOST_DOMAIN_NAME}/htdocs/config.js