From 388a4c88853c6648054e5aef0d35a66ac0c96d05 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 28 Jul 2017 11:17:47 +0100 Subject: [PATCH] Backup the database and content subdirectory for ghost --- src/freedombone-app-ghost | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/freedombone-app-ghost b/src/freedombone-app-ghost index 6c607e98..0c7c98fe 100755 --- a/src/freedombone-app-ghost +++ b/src/freedombone-app-ghost @@ -221,12 +221,12 @@ function backup_local_ghost { GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain") fi - ghost_path=/var/www/${GHOST_DOMAIN_NAME}/htdocs + ghost_path=/var/www/${GHOST_DOMAIN_NAME}/htdocs/content if [ -d $ghost_path ]; then function_check backup_database_to_usb backup_database_to_usb ghost - backup_directory_to_usb $ghost_path ghost + backup_directory_to_usb $ghost_path ghostcontent restart_site fi } @@ -245,6 +245,15 @@ function restore_local_ghost { function_check restore_database 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) ghost_config=/var/www/${GHOST_DOMAIN_NAME}/htdocs/config.js 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") 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 suspend_site ${GHOST_DOMAIN_NAME} backup_database_to_friend ghost - backup_directory_to_friend $temp_backup_dir ghost + backup_directory_to_friend $temp_backup_dir ghostcontent restart_site else 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 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) ghost_config=/var/www/${GHOST_DOMAIN_NAME}/htdocs/config.js