浏览代码

Backup the database and content subdirectory for ghost

Bob Mottram 7 年前
父节点
当前提交
388a4c8885
共有 1 个文件被更改,包括 23 次插入5 次删除
  1. 23
    5
      src/freedombone-app-ghost

+ 23
- 5
src/freedombone-app-ghost 查看文件

@@ -221,12 +221,12 @@ function backup_local_ghost {
221 221
         GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
222 222
     fi
223 223
 
224
-    ghost_path=/var/www/${GHOST_DOMAIN_NAME}/htdocs
224
+    ghost_path=/var/www/${GHOST_DOMAIN_NAME}/htdocs/content
225 225
     if [ -d $ghost_path ]; then
226 226
         function_check backup_database_to_usb
227 227
         backup_database_to_usb ghost
228 228
 
229
-        backup_directory_to_usb $ghost_path ghost
229
+        backup_directory_to_usb $ghost_path ghostcontent
230 230
         restart_site
231 231
     fi
232 232
 }
@@ -245,6 +245,15 @@ function restore_local_ghost {
245 245
         function_check restore_database
246 246
         restore_database ghost ${GHOST_DOMAIN_NAME}
247 247
 
248
+        temp_restore_dir=/root/tempghostcontent
249
+        function_check restore_directory_from_usb
250
+        restore_directory_from_usb $temp_restore_dir ghostcontent
251
+        if [ -d $temp_restore_dir ]; then
252
+            cp -r $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
253
+            chown -R ghost:ghost /var/www/$GHOST_DOMAIN_NAME/htdocs/content
254
+            rm -rf $temp_restore_dir
255
+        fi
256
+
248 257
         MARIADB_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb)
249 258
         ghost_config=/var/www/${GHOST_DOMAIN_NAME}/htdocs/config.js
250 259
         sed -i "s|password :.*|password : '${MARIADB_PASSWORD}',|g" $ghost_config
@@ -278,11 +287,11 @@ function backup_remote_ghost {
278 287
         GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
279 288
     fi
280 289
 
281
-    temp_backup_dir=/var/www/${GHOST_DOMAIN_NAME}/htdocs
290
+    temp_backup_dir=/var/www/${GHOST_DOMAIN_NAME}/htdocs/content
282 291
     if [ -d $temp_backup_dir ]; then
283 292
         suspend_site ${GHOST_DOMAIN_NAME}
284 293
         backup_database_to_friend ghost
285
-        backup_directory_to_friend $temp_backup_dir ghost
294
+        backup_directory_to_friend $temp_backup_dir ghostcontent
286 295
         restart_site
287 296
     else
288 297
         echo $"Ghost domain specified but not found in /var/www/${GHOST_DOMAIN_NAME}"
@@ -306,7 +315,16 @@ function restore_remote_ghost {
306 315
     function_check ghost_create_database
307 316
     ghost_create_database
308 317
 
309
-    restore_database_from_friend ghost ${GHOST_DOMAIN_NAME}
318
+    restore_database_from_friend ghost
319
+
320
+    temp_restore_dir=/root/tempghostcontent
321
+    function_check restore_directory_from_friend
322
+    restore_directory_from_friend $temp_restore_dir ghostcontent
323
+    if [ -d $temp_restore_dir ]; then
324
+        cp -r $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
325
+        chown -R ghost:ghost /var/www/$GHOST_DOMAIN_NAME/htdocs/content
326
+        rm -rf $temp_restore_dir
327
+    fi
310 328
 
311 329
     MARIADB_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb)
312 330
     ghost_config=/var/www/${GHOST_DOMAIN_NAME}/htdocs/config.js