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