瀏覽代碼

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
         GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
221
         GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
222
     fi
222
     fi
223
 
223
 
224
-    ghost_path=/var/www/${GHOST_DOMAIN_NAME}/htdocs
224
+    ghost_path=/var/www/${GHOST_DOMAIN_NAME}/htdocs/content
225
     if [ -d $ghost_path ]; then
225
     if [ -d $ghost_path ]; then
226
         function_check backup_database_to_usb
226
         function_check backup_database_to_usb
227
         backup_database_to_usb ghost
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
         restart_site
230
         restart_site
231
     fi
231
     fi
232
 }
232
 }
245
         function_check restore_database
245
         function_check restore_database
246
         restore_database ghost ${GHOST_DOMAIN_NAME}
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
         MARIADB_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb)
257
         MARIADB_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb)
249
         ghost_config=/var/www/${GHOST_DOMAIN_NAME}/htdocs/config.js
258
         ghost_config=/var/www/${GHOST_DOMAIN_NAME}/htdocs/config.js
250
         sed -i "s|password :.*|password : '${MARIADB_PASSWORD}',|g" $ghost_config
259
         sed -i "s|password :.*|password : '${MARIADB_PASSWORD}',|g" $ghost_config
278
         GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
287
         GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
279
     fi
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
     if [ -d $temp_backup_dir ]; then
291
     if [ -d $temp_backup_dir ]; then
283
         suspend_site ${GHOST_DOMAIN_NAME}
292
         suspend_site ${GHOST_DOMAIN_NAME}
284
         backup_database_to_friend ghost
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
         restart_site
295
         restart_site
287
     else
296
     else
288
         echo $"Ghost domain specified but not found in /var/www/${GHOST_DOMAIN_NAME}"
297
         echo $"Ghost domain specified but not found in /var/www/${GHOST_DOMAIN_NAME}"
306
     function_check ghost_create_database
315
     function_check ghost_create_database
307
     ghost_create_database
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
     MARIADB_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb)
329
     MARIADB_PASSWORD=$(${PROJECT_NAME}-pass -u root -a mariadb)
312
     ghost_config=/var/www/${GHOST_DOMAIN_NAME}/htdocs/config.js
330
     ghost_config=/var/www/${GHOST_DOMAIN_NAME}/htdocs/config.js