ソースを参照

Backup only the necessary gnusocial data

Not all the files
Bob Mottram 7 年 前
コミット
9030522b3a
共有1 個のファイルを変更した92 個の追加35 個の削除を含む
  1. 92
    35
      src/freedombone-app-gnusocial

+ 92
- 35
src/freedombone-app-gnusocial ファイルの表示

@@ -375,21 +375,31 @@ function backup_local_gnusocial {
375 375
         GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
376 376
     fi
377 377
 
378
-    source_directory=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
379
-    if [ -d $source_directory ]; then
380
-        dest_directory=gnusocial
381
-        function_check suspend_site
382
-        suspend_site ${GNUSOCIAL_DOMAIN_NAME}
378
+    source_directory=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/backup
379
+    if [ ! -d $source_directory ]; then
380
+        mkdir $source_directory
381
+    fi
382
+    cp -p /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/config.php $source_directory
383
+    if [ -d /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/static ]; then
384
+        cp -rp /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/static $source_directory
385
+    fi
383 386
 
384
-        function_check backup_directory_to_usb
385
-        backup_directory_to_usb $source_directory $dest_directory
387
+    function_check suspend_site
388
+    suspend_site ${GNUSOCIAL_DOMAIN_NAME}
386 389
 
387
-        function_check backup_database_to_usb
388
-        backup_database_to_usb gnusocial
390
+    function_check backup_directory_to_usb
391
+    dest_directory=gnusocialconfig
392
+    backup_directory_to_usb $source_directory $dest_directory
389 393
 
390
-        function_check restart_site
391
-        restart_site
392
-    fi
394
+    source_directory=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/file
395
+    dest_directory=gnusocialfile
396
+    backup_directory_to_usb $source_directory $dest_directory
397
+
398
+    function_check backup_database_to_usb
399
+    backup_database_to_usb gnusocial
400
+
401
+    function_check restart_site
402
+    restart_site
393 403
 }
394 404
 
395 405
 function restore_local_gnusocial {
@@ -408,8 +418,25 @@ function restore_local_gnusocial {
408 418
         function_check gnusocial_create_database
409 419
         gnusocial_create_database
410 420
 
411
-        restore_database gnusocial ${GNUSOCIAL_DOMAIN_NAME}
421
+        restore_database gnusocial
422
+        if [ -d $temp_restore_dir ]; then
423
+            rm -rf $temp_restore_dir
424
+        fi
425
+
426
+        function_check restore_directory_from_usb
427
+        restore_directory_from_usb $temp_restore_dir gnusocialconfig
428
+        if [ -d $temp_restore_dir ]; then
429
+            cp $temp_restore_dir$gnusocial_dir/backup/config.php $gnusocial_dir/
430
+            chown www-data:www-data $gnusocial_dir/config.php
431
+            cp -rp $temp_restore_dir$gnusocial_dir/static $gnusocial_dir/
432
+            chown -R www-data:www-data $gnusocial_dir/static
433
+            rm -rf $temp_restore_dir
434
+        fi
435
+
436
+        restore_directory_from_usb $temp_restore_dir gnusocialfile
412 437
         if [ -d $temp_restore_dir ]; then
438
+            cp -rp $temp_restore_dir$gnusocial_dir/file $gnusocial_dir/
439
+            chown -R www-data:www-data $gnusocial_dir/file
413 440
             rm -rf $temp_restore_dir
414 441
         fi
415 442
 
@@ -420,45 +447,75 @@ function restore_local_gnusocial {
420 447
 }
421 448
 
422 449
 function backup_remote_gnusocial {
450
+    GNUSOCIAL_DOMAIN_NAME='gnusocial'
423 451
     if grep -q "gnusocial domain" $COMPLETION_FILE; then
424 452
         GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
425
-        temp_backup_dir=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
426
-        if [ -d $temp_backup_dir ]; then
427
-            function_check suspend_site
428
-            suspend_site ${GNUSOCIAL_DOMAIN_NAME}
453
+    fi
429 454
 
430
-            function_check backup_database_to_friend
431
-            backup_database_to_friend gnusocial
455
+    source_directory=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/backup
456
+    if [ ! -d $source_directory ]; then
457
+        mkdir $source_directory
458
+    fi
459
+    cp -p /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/config.php $source_directory
460
+    if [ -d /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/static ]; then
461
+        cp -rp /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/static $source_directory
462
+    fi
432 463
 
433
-            echo $"Backing up GNU social installation"
464
+    function_check suspend_site
465
+    suspend_site ${GNUSOCIAL_DOMAIN_NAME}
434 466
 
435
-            function_check backup_directory_to_friend
436
-            backup_directory_to_friend $temp_backup_dir gnusocial
467
+    function_check backup_directory_to_friend
468
+    dest_directory=gnusocialconfig
469
+    backup_directory_to_friend $source_directory $dest_directory
437 470
 
438
-            function_check restart_site
439
-            restart_site
440
-        else
441
-            echo $"gnusocial domain specified but not found in ${temp_backup_dir}"
442
-        fi
443
-    fi
471
+    source_directory=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/file
472
+    dest_directory=gnusocialfile
473
+    backup_directory_to_friend $source_directory $dest_directory
474
+
475
+    function_check backup_database_to_friend
476
+    backup_database_to_friend gnusocial
477
+
478
+    function_check restart_site
479
+    restart_site
444 480
 }
445 481
 
446 482
 function restore_remote_gnusocial {
447
-    if grep -q "gnusocial domain" $COMPLETION_FILE; then
483
+    if ! grep -q "gnusocial domain" $COMPLETION_FILE; then
484
+        return
485
+    fi
486
+    GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
487
+    if [ $GNUSOCIAL_DOMAIN_NAME ]; then
448 488
         echo $"Restoring gnusocial"
449
-        GNUSOCIAL_DOMAIN_NAME=$(get_completion_param "gnusocial domain")
450
-
489
+        temp_restore_dir=/root/tempgnusocial
490
+        gnusocial_dir=/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
451 491
         # stop the daemons
452
-        cd /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
492
+        cd $gnusocial_dir
453 493
         scripts/stopdaemons.sh
454 494
 
455 495
         function_check gnusocial_create_database
456 496
         gnusocial_create_database
457 497
 
458 498
         function_check restore_database_from_friend
459
-        restore_database_from_friend gnusocial ${GNUSOCIAL_DOMAIN_NAME}
460
-        if [ -d /root/tempgnusocial ]; then
461
-            rm -rf /root/tempgnusocial
499
+        restore_database_from_friend gnusocial
500
+        if [ -d $temp_restore_dir ]; then
501
+            rm -rf $temp_restore_dir
502
+        fi
503
+
504
+        function_check restore_directory_from_friend
505
+        restore_directory_from_friend $temp_restore_dir gnusocialconfig
506
+        if [ -d $temp_restore_dir ]; then
507
+            cp $temp_restore_dir$gnusocial_dir/backup/config.php $gnusocial_dir/
508
+            chown www-data:www-data $gnusocial_dir/config.php
509
+            cp -rp $temp_restore_dir$gnusocial_dir/static $gnusocial_dir/
510
+            chown -R www-data:www-data $gnusocial_dir/static
511
+            rm -rf $temp_restore_dir
512
+        fi
513
+
514
+        restore_directory_from_friend $temp_restore_dir gnusocialfile
515
+        if [ -d $temp_restore_dir ]; then
516
+            cp -rp $temp_restore_dir$gnusocial_dir/file $gnusocial_dir/
517
+            chown -R www-data:www-data $gnusocial_dir/file
518
+            rm -rf $temp_restore_dir
462 519
         fi
463 520
 
464 521
         gnusocial_update_after_restore gnusocial ${GNUSOCIAL_DOMAIN_NAME}