Bladeren bron

Ability to restore specific apps

Bob Mottram 9 jaren geleden
bovenliggende
commit
178b0029fd
2 gewijzigde bestanden met toevoegingen van 145 en 1 verwijderingen
  1. BIN
      man/freedombone-restore-local.1.gz
  2. 145
    1
      src/freedombone-restore-local

BIN
man/freedombone-restore-local.1.gz Bestand weergeven


+ 145
- 1
src/freedombone-restore-local Bestand weergeven

32
 COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
32
 COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
33
 BACKUP_EXTRA_DIRECTORIES=/root/backup-extra-dirs.csv
33
 BACKUP_EXTRA_DIRECTORIES=/root/backup-extra-dirs.csv
34
 
34
 
35
+# whether to restore everything or just a specific application
36
+RESTORE_APP='all'
37
+
35
 export TEXTDOMAIN=${PROJECT_NAME}-restore-local
38
 export TEXTDOMAIN=${PROJECT_NAME}-restore-local
36
 export TEXTDOMAINDIR="/usr/share/locale"
39
 export TEXTDOMAINDIR="/usr/share/locale"
37
 
40
 
228
 }
231
 }
229
 
232
 
230
 function restore_configuration {
233
 function restore_configuration {
234
+    if [[ $RESTORE_APP != 'all' ]]; then
235
+        if [[ $RESTORE_APP != 'configuration' ]]; then
236
+            return
237
+        fi
238
+    fi
239
+
231
     # this restores *.cfg and COMPLETION_FILE
240
     # this restores *.cfg and COMPLETION_FILE
232
     if [ -d $USB_MOUNT/backup/config ]; then
241
     if [ -d $USB_MOUNT/backup/config ]; then
233
         echo $"Restoring configuration files"
242
         echo $"Restoring configuration files"
274
 }
283
 }
275
 
284
 
276
 function restore_mariadb {
285
 function restore_mariadb {
286
+    if [[ $RESTORE_APP != 'all' ]]; then
287
+        if [[ $RESTORE_APP != 'mariadb' ]]; then
288
+            return
289
+        fi
290
+    fi
277
     if [ -d $USB_MOUNT/backup/mariadb ]; then
291
     if [ -d $USB_MOUNT/backup/mariadb ]; then
278
         echo $"Restoring mysql settings"
292
         echo $"Restoring mysql settings"
279
         restore_directory_from_usb /root/tempmariadb mariadb
293
         restore_directory_from_usb /root/tempmariadb mariadb
310
 }
324
 }
311
 
325
 
312
 function restore_letsencrypt {
326
 function restore_letsencrypt {
327
+    if [[ $RESTORE_APP != 'all' ]]; then
328
+        if [[ $RESTORE_APP != 'letsencrypt' ]]; then
329
+            return
330
+        fi
331
+    fi
313
     if [ -d $USB_MOUNT/backup/letsencrypt ]; then
332
     if [ -d $USB_MOUNT/backup/letsencrypt ]; then
314
         echo $"Restoring Lets Encrypt settings"
333
         echo $"Restoring Lets Encrypt settings"
315
         restore_directory_from_usb / letsencrypt
334
         restore_directory_from_usb / letsencrypt
317
 }
336
 }
318
 
337
 
319
 function restore_mutt_settings {
338
 function restore_mutt_settings {
339
+    if [[ $RESTORE_APP != 'all' ]]; then
340
+        if [[ $RESTORE_APP != 'mutt' ]]; then
341
+            return
342
+        fi
343
+    fi
320
     if [ -d $USB_MOUNT/backup/mutt ]; then
344
     if [ -d $USB_MOUNT/backup/mutt ]; then
321
         for d in $USB_MOUNT/backup/mutt/*/ ; do
345
         for d in $USB_MOUNT/backup/mutt/*/ ; do
322
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
346
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
344
 }
368
 }
345
 
369
 
346
 function restore_gpg {
370
 function restore_gpg {
371
+    if [[ $RESTORE_APP != 'all' ]]; then
372
+        if [[ $RESTORE_APP != 'gpg' ]]; then
373
+            return
374
+        fi
375
+    fi
347
     if [ -d $USB_MOUNT/backup/gnupg ]; then
376
     if [ -d $USB_MOUNT/backup/gnupg ]; then
348
         for d in $USB_MOUNT/backup/gnupg/*/ ; do
377
         for d in $USB_MOUNT/backup/gnupg/*/ ; do
349
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
378
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
373
 }
402
 }
374
 
403
 
375
 function restore_procmail {
404
 function restore_procmail {
405
+    if [[ $RESTORE_APP != 'all' ]]; then
406
+        if [[ $RESTORE_APP != 'procmail' ]]; then
407
+            return
408
+        fi
409
+    fi
376
     if [ -d $USB_MOUNT/backup/procmail ]; then
410
     if [ -d $USB_MOUNT/backup/procmail ]; then
377
         for d in $USB_MOUNT/backup/procmail/*/ ; do
411
         for d in $USB_MOUNT/backup/procmail/*/ ; do
378
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
412
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
395
 }
429
 }
396
 
430
 
397
 function restore_spamassassin {
431
 function restore_spamassassin {
432
+    if [[ $RESTORE_APP != 'all' ]]; then
433
+        if [[ $RESTORE_APP != 'spamassassin' ]]; then
434
+            return
435
+        fi
436
+    fi
398
     if [ -d $USB_MOUNT/backup/spamassassin ]; then
437
     if [ -d $USB_MOUNT/backup/spamassassin ]; then
399
         for d in $USB_MOUNT/backup/spamassassin/*/ ; do
438
         for d in $USB_MOUNT/backup/spamassassin/*/ ; do
400
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
439
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
419
 }
458
 }
420
 
459
 
421
 function restore_admin_readme {
460
 function restore_admin_readme {
461
+    if [[ $RESTORE_APP != 'all' ]]; then
462
+        if [[ $RESTORE_APP != 'readme' ]]; then
463
+            return
464
+        fi
465
+    fi
422
     if [ -d $USB_MOUNT/backup/readme ]; then
466
     if [ -d $USB_MOUNT/backup/readme ]; then
423
         echo $"Restoring admin user README"
467
         echo $"Restoring admin user README"
424
 
468
 
442
 }
486
 }
443
 
487
 
444
 function restore_ipfs {
488
 function restore_ipfs {
489
+    if [[ $RESTORE_APP != 'all' ]]; then
490
+        if [[ $RESTORE_APP != 'ipfs' ]]; then
491
+            return
492
+        fi
493
+    fi
445
     if [ -d $USB_MOUNT/backup/ipfs ]; then
494
     if [ -d $USB_MOUNT/backup/ipfs ]; then
446
         echo $"Restoring IPFS"
495
         echo $"Restoring IPFS"
447
         restore_directory_from_usb /root/tempipfs ipfs
496
         restore_directory_from_usb /root/tempipfs ipfs
456
 }
505
 }
457
 
506
 
458
 function restore_user_ssh_keys {
507
 function restore_user_ssh_keys {
508
+    if [[ $RESTORE_APP != 'all' ]]; then
509
+        if [[ $RESTORE_APP != 'ssh' ]]; then
510
+            return
511
+        fi
512
+    fi
459
     if [ -d $USB_MOUNT/backup/ssh ]; then
513
     if [ -d $USB_MOUNT/backup/ssh ]; then
460
         for d in $USB_MOUNT/backup/ssh/*/ ; do
514
         for d in $USB_MOUNT/backup/ssh/*/ ; do
461
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
515
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
478
 }
532
 }
479
 
533
 
480
 function restore_user_config {
534
 function restore_user_config {
535
+    if [[ $RESTORE_APP != 'all' ]]; then
536
+        if [[ $RESTORE_APP != 'userconfig' ]]; then
537
+            return
538
+        fi
539
+    fi
481
     if [ -d $USB_MOUNT/backup/config ]; then
540
     if [ -d $USB_MOUNT/backup/config ]; then
482
         for d in $USB_MOUNT/backup/config/*/ ; do
541
         for d in $USB_MOUNT/backup/config/*/ ; do
483
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
542
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
500
 }
559
 }
501
 
560
 
502
 function restore_certs {
561
 function restore_certs {
562
+    if [[ $RESTORE_APP != 'all' ]]; then
563
+        if [[ $RESTORE_APP != 'certs' ]]; then
564
+            return
565
+        fi
566
+    fi
503
     if [ -d $USB_MOUNT/backup/ssl ]; then
567
     if [ -d $USB_MOUNT/backup/ssl ]; then
504
         echo $"Restoring certificates"
568
         echo $"Restoring certificates"
505
         mkdir /root/tempssl
569
         mkdir /root/tempssl
514
 }
578
 }
515
 
579
 
516
 function restore_personal_settings {
580
 function restore_personal_settings {
581
+    if [[ $RESTORE_APP != 'all' ]]; then
582
+        if [[ $RESTORE_APP != 'personal' ]]; then
583
+            return
584
+        fi
585
+    fi
517
     if [ -d $USB_MOUNT/backup/personal ]; then
586
     if [ -d $USB_MOUNT/backup/personal ]; then
518
         for d in $USB_MOUNT/backup/personal/*/ ; do
587
         for d in $USB_MOUNT/backup/personal/*/ ; do
519
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
588
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
540
 }
609
 }
541
 
610
 
542
 function restore_mailing_list {
611
 function restore_mailing_list {
612
+    if [[ $RESTORE_APP != 'all' ]]; then
613
+        if [[ $RESTORE_APP != 'mailinglist' ]]; then
614
+            return
615
+        fi
616
+    fi
543
     if [ -d /var/spool/mlmmj ]; then
617
     if [ -d /var/spool/mlmmj ]; then
544
         echo $"Restoring public mailing list"
618
         echo $"Restoring public mailing list"
545
         restore_directory_from_usb /root/tempmailinglist mailinglist
619
         restore_directory_from_usb /root/tempmailinglist mailinglist
553
 }
627
 }
554
 
628
 
555
 function restore_xmpp {
629
 function restore_xmpp {
630
+    if [[ $RESTORE_APP != 'all' ]]; then
631
+        if [[ $RESTORE_APP != 'xmpp' ]]; then
632
+            return
633
+        fi
634
+    fi
556
     if [ -d /var/lib/prosody ]; then
635
     if [ -d /var/lib/prosody ]; then
557
         echo $"Restoring XMPP settings"
636
         echo $"Restoring XMPP settings"
558
         restore_directory_from_usb /root/tempxmpp xmpp
637
         restore_directory_from_usb /root/tempxmpp xmpp
568
 }
647
 }
569
 
648
 
570
 function restore_gnu_social {
649
 function restore_gnu_social {
650
+    if [[ $RESTORE_APP != 'all' ]]; then
651
+        if [[ $RESTORE_APP != 'gnusocial' ]]; then
652
+            return
653
+        fi
654
+    fi
571
     if [ $MICROBLOG_DOMAIN_NAME ]; then
655
     if [ $MICROBLOG_DOMAIN_NAME ]; then
572
         restore_database gnusocial ${MICROBLOG_DOMAIN_NAME}
656
         restore_database gnusocial ${MICROBLOG_DOMAIN_NAME}
573
         if [ -d /root/tempgnusocial ]; then
657
         if [ -d /root/tempgnusocial ]; then
577
 }
661
 }
578
 
662
 
579
 function restore_hubzilla {
663
 function restore_hubzilla {
664
+    if [[ $RESTORE_APP != 'all' ]]; then
665
+        if [[ $RESTORE_APP != 'hubzilla' ]]; then
666
+            return
667
+        fi
668
+    fi
580
     if [ $HUBZILLA_DOMAIN_NAME ]; then
669
     if [ $HUBZILLA_DOMAIN_NAME ]; then
581
         restore_database hubzilla ${HUBZILLA_DOMAIN_NAME}
670
         restore_database hubzilla ${HUBZILLA_DOMAIN_NAME}
582
         if [ -d $USB_MOUNT/backup/hubzilla ]; then
671
         if [ -d $USB_MOUNT/backup/hubzilla ]; then
593
 }
682
 }
594
 
683
 
595
 function restore_owncloud {
684
 function restore_owncloud {
685
+    if [[ $RESTORE_APP != 'all' ]]; then
686
+        if [[ $RESTORE_APP != 'owncloud' ]]; then
687
+            return
688
+        fi
689
+    fi
596
     if [ $OWNCLOUD_DOMAIN_NAME ]; then
690
     if [ $OWNCLOUD_DOMAIN_NAME ]; then
597
         restore_database owncloud $OWNCLOUD_DOMAIN_NAME
691
         restore_database owncloud $OWNCLOUD_DOMAIN_NAME
598
         if [ -d $USB_MOUNT/backup/owncloud2 ]; then
692
         if [ -d $USB_MOUNT/backup/owncloud2 ]; then
619
 }
713
 }
620
 
714
 
621
 function restore_gogs {
715
 function restore_gogs {
716
+    if [[ $RESTORE_APP != 'all' ]]; then
717
+        if [[ $RESTORE_APP != 'gogs' ]]; then
718
+            return
719
+        fi
720
+    fi
622
     if [ $GIT_DOMAIN_NAME ]; then
721
     if [ $GIT_DOMAIN_NAME ]; then
623
         restore_database gogs ${GIT_DOMAIN_NAME}
722
         restore_database gogs ${GIT_DOMAIN_NAME}
624
         if [ -d $USB_MOUNT/backup/gogs ]; then
723
         if [ -d $USB_MOUNT/backup/gogs ]; then
657
 }
756
 }
658
 
757
 
659
 function restore_wiki {
758
 function restore_wiki {
759
+    if [[ $RESTORE_APP != 'all' ]]; then
760
+        if [[ $RESTORE_APP != 'wiki' ]]; then
761
+            return
762
+        fi
763
+    fi
660
     if [ $WIKI_DOMAIN_NAME ]; then
764
     if [ $WIKI_DOMAIN_NAME ]; then
661
         echo $"Restoring Wiki installation ${WIKI_DOMAIN_NAME}"
765
         echo $"Restoring Wiki installation ${WIKI_DOMAIN_NAME}"
662
         restore_directory_from_usb /root/tempwiki wiki
766
         restore_directory_from_usb /root/tempwiki wiki
686
 }
790
 }
687
 
791
 
688
 function restore_blog {
792
 function restore_blog {
793
+    if [[ $RESTORE_APP != 'all' ]]; then
794
+        if [[ $RESTORE_APP != 'blog' ]]; then
795
+            return
796
+        fi
797
+    fi
689
     if [ $FULLBLOG_DOMAIN_NAME ]; then
798
     if [ $FULLBLOG_DOMAIN_NAME ]; then
690
         echo $"Restoring blog installation"
799
         echo $"Restoring blog installation"
691
         restore_directory_from_usb /root/tempblog blog
800
         restore_directory_from_usb /root/tempblog blog
722
 }
831
 }
723
 
832
 
724
 function restore_cjdns {
833
 function restore_cjdns {
834
+    if [[ $RESTORE_APP != 'all' ]]; then
835
+        if [[ $RESTORE_APP != 'cjdns' ]]; then
836
+            return
837
+        fi
838
+    fi
725
     if [ -d $USB_MOUNT/backup/cjdns ]; then
839
     if [ -d $USB_MOUNT/backup/cjdns ]; then
726
         echo $"Restoring cjdns installation"
840
         echo $"Restoring cjdns installation"
727
         restore_directory_from_usb /root/tempcjdns cjdns
841
         restore_directory_from_usb /root/tempcjdns cjdns
736
 }
850
 }
737
 
851
 
738
 function restore_email {
852
 function restore_email {
853
+    if [[ $RESTORE_APP != 'all' ]]; then
854
+        if [[ $RESTORE_APP != 'email' ]]; then
855
+            return
856
+        fi
857
+    fi
739
     if [ -d $USB_MOUNT/backup/mail ]; then
858
     if [ -d $USB_MOUNT/backup/mail ]; then
740
         for d in $USB_MOUNT/backup/mail/*/ ; do
859
         for d in $USB_MOUNT/backup/mail/*/ ; do
741
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
860
             USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
760
 }
879
 }
761
 
880
 
762
 function restore_dlna {
881
 function restore_dlna {
882
+    if [[ $RESTORE_APP != 'all' ]]; then
883
+        if [[ $RESTORE_APP != 'dlna' ]]; then
884
+            return
885
+        fi
886
+    fi
763
     if [ -d /var/cache/minidlna ]; then
887
     if [ -d /var/cache/minidlna ]; then
764
         if [ -d $USB_MOUNT/backup/dlna ]; then
888
         if [ -d $USB_MOUNT/backup/dlna ]; then
765
             echo $"Restoring DLNA cache"
889
             echo $"Restoring DLNA cache"
776
 }
900
 }
777
 
901
 
778
 function restore_voip {
902
 function restore_voip {
903
+    if [[ $RESTORE_APP != 'all' ]]; then
904
+        if [[ $RESTORE_APP != 'voip' ]]; then
905
+            return
906
+        fi
907
+    fi
779
     if [ -d $USB_MOUNT/backup/voip ]; then
908
     if [ -d $USB_MOUNT/backup/voip ]; then
780
         echo $"Restoring VoIP settings"
909
         echo $"Restoring VoIP settings"
781
         restore_directory_from_usb /root/tempvoip voip
910
         restore_directory_from_usb /root/tempvoip voip
807
 }
936
 }
808
 
937
 
809
 function restore_tox {
938
 function restore_tox {
939
+    if [[ $RESTORE_APP != 'all' ]]; then
940
+        if [[ $RESTORE_APP != 'tox' ]]; then
941
+            return
942
+        fi
943
+    fi
810
     if [ -d $USB_MOUNT/backup/tox ]; then
944
     if [ -d $USB_MOUNT/backup/tox ]; then
811
         echo $"Restoring Tox node settings"
945
         echo $"Restoring Tox node settings"
812
         restore_directory_from_usb / tox
946
         restore_directory_from_usb / tox
824
     fi
958
     fi
825
 }
959
 }
826
 
960
 
827
-mount_drive $1 $2
961
+function get_restore_app {
962
+    if [ ${1} ]; then
963
+        if [ ! -d /home/${1} ]; then
964
+            RESTORE_APP=${1}
965
+            echo $"Restore $RESTORE_APP"
966
+        fi
967
+    fi
968
+}
969
+
970
+get_restore_app ${2}
971
+mount_drive ${1} ${2}
828
 check_backup_exists
972
 check_backup_exists
829
 check_admin_user
973
 check_admin_user
830
 copy_gpg_keys
974
 copy_gpg_keys