浏览代码

Ghost backup and restore when database is in the current subdirectory

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

+ 57
- 6
src/freedombone-app-ghost 查看文件

228
         GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
228
         GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
229
     fi
229
     fi
230
 
230
 
231
+    suspend_site ${GHOST_DOMAIN_NAME}
232
+    systemctl stop ghost
233
+
231
     ghost_path=/var/www/${GHOST_DOMAIN_NAME}/htdocs/content
234
     ghost_path=/var/www/${GHOST_DOMAIN_NAME}/htdocs/content
232
     if [ -d $ghost_path ]; then
235
     if [ -d $ghost_path ]; then
233
-        suspend_site ${GHOST_DOMAIN_NAME}
234
-        systemctl stop ghost
235
         backup_directory_to_usb $ghost_path ghostcontent
236
         backup_directory_to_usb $ghost_path ghostcontent
236
-        systemctl start ghost
237
-        restart_site
238
     fi
237
     fi
238
+
239
+    ghost_path=/var/www/${GHOST_DOMAIN_NAME}/htdocs/current/content
240
+    if [ -d $ghost_path ]; then
241
+        backup_directory_to_usb $ghost_path ghostcurrent
242
+    fi
243
+
244
+    systemctl start ghost
245
+    restart_site
239
 }
246
 }
240
 
247
 
241
 function restore_local_ghost {
248
 function restore_local_ghost {
263
             rm -rf $temp_restore_dir
270
             rm -rf $temp_restore_dir
264
         fi
271
         fi
265
 
272
 
273
+        temp_restore_dir=/root/tempghostcurrent
274
+        function_check restore_directory_from_usb
275
+        restore_directory_from_usb $temp_restore_dir ghostcurrent
276
+        if [ -d $temp_restore_dir ]; then
277
+            if [ -d $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/current/content ]; then
278
+                cp -r $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/current/content/* /var/www/$GHOST_DOMAIN_NAME/htdocs/current/content/
279
+            else
280
+                if [ ! -d /var/www/$GHOST_DOMAIN_NAME/htdocs/current/content ]; then
281
+                    mkdir -p /var/www/$GHOST_DOMAIN_NAME/htdocs/current/content
282
+                fi
283
+                cp -r $temp_restore_dir/* /var/www/$GHOST_DOMAIN_NAME/htdocs/current/content/
284
+            fi
285
+            chown -R ghost:ghost /var/www/$GHOST_DOMAIN_NAME/htdocs/current/content
286
+            rm -rf $temp_restore_dir
287
+        fi
288
+
266
         systemctl start ghost
289
         systemctl start ghost
267
         restart_site
290
         restart_site
268
     fi
291
     fi
274
         GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
297
         GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
275
     fi
298
     fi
276
 
299
 
300
+    suspend_site ${GHOST_DOMAIN_NAME}
301
+
277
     temp_backup_dir=/var/www/${GHOST_DOMAIN_NAME}/htdocs/content
302
     temp_backup_dir=/var/www/${GHOST_DOMAIN_NAME}/htdocs/content
278
     if [ -d $temp_backup_dir ]; then
303
     if [ -d $temp_backup_dir ]; then
279
-        suspend_site ${GHOST_DOMAIN_NAME}
280
         backup_directory_to_friend $temp_backup_dir ghostcontent
304
         backup_directory_to_friend $temp_backup_dir ghostcontent
281
-        restart_site
282
     else
305
     else
306
+        restart_site
283
         echo $"Ghost domain specified but not found in /var/www/${GHOST_DOMAIN_NAME}"
307
         echo $"Ghost domain specified but not found in /var/www/${GHOST_DOMAIN_NAME}"
284
         exit 2578
308
         exit 2578
285
     fi
309
     fi
310
+
311
+    temp_backup_dir=/var/www/${GHOST_DOMAIN_NAME}/htdocs/current/content
312
+    if [ -d $temp_backup_dir ]; then
313
+        backup_directory_to_friend $temp_backup_dir ghostcurrent
314
+    else
315
+        restart_site
316
+        echo $"Ghost domain specified but not found in $temp_backup_dir"
317
+        exit 78353
318
+    fi
319
+
320
+    restart_site
286
 }
321
 }
287
 
322
 
288
 function restore_remote_ghost {
323
 function restore_remote_ghost {
310
         rm -rf $temp_restore_dir
345
         rm -rf $temp_restore_dir
311
     fi
346
     fi
312
 
347
 
348
+    temp_restore_dir=/root/tempghostcurrent
349
+    function_check restore_directory_from_friend
350
+    restore_directory_from_friend $temp_restore_dir ghostcurrent
351
+    if [ -d $temp_restore_dir ]; then
352
+        if [ -d $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/current/content ]; then
353
+            cp -r $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/current/content/* /var/www/$GHOST_DOMAIN_NAME/htdocs/current/content/
354
+        else
355
+            if [ ! -d /var/www/$GHOST_DOMAIN_NAME/htdocs/current/content ]; then
356
+                mkdir -p /var/www/$GHOST_DOMAIN_NAME/htdocs/current/content
357
+            fi
358
+            cp -r $temp_restore_dir/* /var/www/$GHOST_DOMAIN_NAME/htdocs/current/content/
359
+        fi
360
+        chown -R ghost: /var/www/$GHOST_DOMAIN_NAME/htdocs
361
+        rm -rf $temp_restore_dir
362
+    fi
363
+
313
     systemctl start ghost
364
     systemctl start ghost
314
     restart_site
365
     restart_site
315
 }
366
 }