Browse Source

Remote restore of specific applications

Bob Mottram 9 years ago
parent
commit
0467fb24f8

BIN
man/freedombone-restore-local.1.gz View File


BIN
man/freedombone-restore-remote.1.gz View File


+ 137
- 0
src/freedombone-restore-remote View File

@@ -38,6 +38,13 @@ export TEXTDOMAINDIR="/usr/share/locale"
38 38
 
39 39
 SERVER_NAME=$1
40 40
 
41
+# whether to restore everything or just a specific application
42
+RESTORE_APP='all'
43
+
44
+if [ ${2} ]; then
45
+    RESTORE_APP=${2}
46
+fi
47
+
41 48
 ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | -nawk -F ':' '{print $2}')
42 49
 ADMIN_EMAIL_ADDRESS=${ADMIN_USERNAME}@${HOSTNAME}
43 50
 
@@ -139,6 +146,11 @@ function restore_database_from_friend {
139 146
 }
140 147
 
141 148
 function restore_configuration {
149
+    if [[ $RESTORE_APP != 'all' ]]; then
150
+        if [[ $RESTORE_APP != 'configuration' ]]; then
151
+            return
152
+        fi
153
+    fi
142 154
     if [ -d $SERVER_DIRECTORY/backup/config ]; then
143 155
         echo $"Restoring configuration files"
144 156
         restore_directory_from_friend /root/tempconfig config
@@ -175,6 +187,11 @@ function restore_configuration {
175 187
 }
176 188
 
177 189
 function restore_mariadb {
190
+    if [[ $RESTORE_APP != 'all' ]]; then
191
+        if [[ $RESTORE_APP != 'mariadb' ]]; then
192
+            return
193
+        fi
194
+    fi
178 195
     if [ -d $SERVER_DIRECTORY/backup/mariadb ]; then
179 196
         echo $"Restoring MariaDB settings"
180 197
         restore_directory_from_friend /root/tempmariadb mariadb
@@ -210,6 +227,11 @@ function restore_mariadb {
210 227
 }
211 228
 
212 229
 function restore_letsencrypt {
230
+    if [[ $RESTORE_APP != 'all' ]]; then
231
+        if [[ $RESTORE_APP != 'letsencrypt' ]]; then
232
+            return
233
+        fi
234
+    fi
213 235
     if [ -d $SERVER_DIRECTORY/backup/letsencrypt ]; then
214 236
         echo $"Restoring Lets Encrypt settings"
215 237
         restore_directory_from_friend / letsencrypt
@@ -217,6 +239,11 @@ function restore_letsencrypt {
217 239
 }
218 240
 
219 241
 function restore_mutt_settings {
242
+    if [[ $RESTORE_APP != 'all' ]]; then
243
+        if [[ $RESTORE_APP != 'mutt' ]]; then
244
+            return
245
+        fi
246
+    fi
220 247
     for d in $SERVER_DIRECTORY/backup/mutt/*/ ; do
221 248
         USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
222 249
         if [[ $USERNAME != "git" ]]; then
@@ -243,6 +270,11 @@ function restore_mutt_settings {
243 270
 }
244 271
 
245 272
 function restore_gpg {
273
+    if [[ $RESTORE_APP != 'all' ]]; then
274
+        if [[ $RESTORE_APP != 'gpg' ]]; then
275
+            return
276
+        fi
277
+    fi
246 278
     for d in $SERVER_DIRECTORY/backup/gnupg/*/ ; do
247 279
         USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
248 280
         if [[ $USERNAME != "git" ]]; then
@@ -270,6 +302,11 @@ function restore_gpg {
270 302
 }
271 303
 
272 304
 function restore_procmail {
305
+    if [[ $RESTORE_APP != 'all' ]]; then
306
+        if [[ $RESTORE_APP != 'procmail' ]]; then
307
+            return
308
+        fi
309
+    fi
273 310
     for d in $SERVER_DIRECTORY/backup/procmail/*/ ; do
274 311
         USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
275 312
         if [[ $USERNAME != "git" ]]; then
@@ -291,6 +328,11 @@ function restore_procmail {
291 328
 }
292 329
 
293 330
 function restore_spamassassin {
331
+    if [[ $RESTORE_APP != 'all' ]]; then
332
+        if [[ $RESTORE_APP != 'spamassassin' ]]; then
333
+            return
334
+        fi
335
+    fi
294 336
     for d in $SERVER_DIRECTORY/backup/spamassassin/*/ ; do
295 337
         USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
296 338
         if [[ $USERNAME != "git" ]]; then
@@ -312,6 +354,11 @@ function restore_spamassassin {
312 354
 }
313 355
 
314 356
 function restore_admin_readme {
357
+    if [[ $RESTORE_APP != 'all' ]]; then
358
+        if [[ $RESTORE_APP != 'readme' ]]; then
359
+            return
360
+        fi
361
+    fi
315 362
     if [ -d $SERVER_DIRECTORY/backup/readme ]; then
316 363
         echo $"Restoring README"
317 364
         restore_directory_from_friend /root/tempreadme readme
@@ -325,6 +372,11 @@ function restore_admin_readme {
325 372
 }
326 373
 
327 374
 function restore_ipfs {
375
+    if [[ $RESTORE_APP != 'all' ]]; then
376
+        if [[ $RESTORE_APP != 'ipfs' ]]; then
377
+            return
378
+        fi
379
+    fi
328 380
     if [ -d $SERVER_DIRECTORY/backup/ipfs ]; then
329 381
         echo $"Restoring IPFS"
330 382
         restore_directory_from_friend /root/tempipfs ipfs
@@ -338,6 +390,11 @@ function restore_ipfs {
338 390
 }
339 391
 
340 392
 function restore_ssh_keys {
393
+    if [[ $RESTORE_APP != 'all' ]]; then
394
+        if [[ $RESTORE_APP != 'ssh' ]]; then
395
+            return
396
+        fi
397
+    fi
341 398
     for d in $SERVER_DIRECTORY/backup/ssh/*/ ; do
342 399
         USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
343 400
         if [[ $USERNAME != "git" ]]; then
@@ -359,6 +416,11 @@ function restore_ssh_keys {
359 416
 }
360 417
 
361 418
 function restore_user_config {
419
+    if [[ $RESTORE_APP != 'all' ]]; then
420
+        if [[ $RESTORE_APP != 'userconfig' ]]; then
421
+            return
422
+        fi
423
+    fi
362 424
     for d in $SERVER_DIRECTORY/backup/config/*/ ; do
363 425
         USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
364 426
         if [[ $USERNAME != "git" ]]; then
@@ -380,6 +442,11 @@ function restore_user_config {
380 442
 }
381 443
 
382 444
 function restore_certs {
445
+    if [[ $RESTORE_APP != 'all' ]]; then
446
+        if [[ $RESTORE_APP != 'certs' ]]; then
447
+            return
448
+        fi
449
+    fi
383 450
     if [ -d $SERVER_DIRECTORY/backup/ssl ]; then
384 451
         echo $"Restoring certificates"
385 452
         restore_directory_from_friend /root/tempssl ssl
@@ -392,6 +459,11 @@ function restore_certs {
392 459
 }
393 460
 
394 461
 function restore_personal_settings {
462
+    if [[ $RESTORE_APP != 'all' ]]; then
463
+        if [[ $RESTORE_APP != 'personal' ]]; then
464
+            return
465
+        fi
466
+    fi
395 467
     for d in $SERVER_DIRECTORY/backup/personal/*/ ; do
396 468
         USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
397 469
         if [[ $USERNAME != "git" ]]; then
@@ -415,6 +487,11 @@ function restore_personal_settings {
415 487
 }
416 488
 
417 489
 function restore_mailing_list {
490
+    if [[ $RESTORE_APP != 'all' ]]; then
491
+        if [[ $RESTORE_APP != 'mailinglist' ]]; then
492
+            return
493
+        fi
494
+    fi
418 495
     if [ -d /var/spool/mlmmj ]; then
419 496
         echo $"Restoring public mailing list"
420 497
         restore_directory_from_friend /root/tempmailinglist mailinglist
@@ -427,6 +504,11 @@ function restore_mailing_list {
427 504
 }
428 505
 
429 506
 function restore_xmpp {
507
+    if [[ $RESTORE_APP != 'all' ]]; then
508
+        if [[ $RESTORE_APP != 'xmpp' ]]; then
509
+            return
510
+        fi
511
+    fi
430 512
     if [ -d /var/lib/prosody ]; then
431 513
         echo $"Restoring XMPP settings"
432 514
         restore_directory_from_friend /root/tempxmpp xmpp
@@ -441,6 +523,11 @@ function restore_xmpp {
441 523
 }
442 524
 
443 525
 function restore_gnu_social {
526
+    if [[ $RESTORE_APP != 'all' ]]; then
527
+        if [[ $RESTORE_APP != 'gnusocial' ]]; then
528
+            return
529
+        fi
530
+    fi
444 531
     if grep -q "GNU Social domain" $COMPLETION_FILE; then
445 532
         MICROBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "GNU Social domain" | awk -F ':' '{print $2}')
446 533
         restore_database_from_friend gnusocial ${MICROBLOG_DOMAIN_NAME}
@@ -451,6 +538,11 @@ function restore_gnu_social {
451 538
 }
452 539
 
453 540
 function restore_hubzilla {
541
+    if [[ $RESTORE_APP != 'all' ]]; then
542
+        if [[ $RESTORE_APP != 'hubzilla' ]]; then
543
+            return
544
+        fi
545
+    fi
454 546
     if grep -q "Hubzilla domain" $COMPLETION_FILE; then
455 547
         HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
456 548
         restore_database_from_friend hubzilla ${HUBZILLA_DOMAIN_NAME}
@@ -468,6 +560,11 @@ function restore_hubzilla {
468 560
 }
469 561
 
470 562
 function restore_owncloud {
563
+    if [[ $RESTORE_APP != 'all' ]]; then
564
+        if [[ $RESTORE_APP != 'owncloud' ]]; then
565
+            return
566
+        fi
567
+    fi
471 568
     if grep -q "Owncloud domain" $COMPLETION_FILE; then
472 569
         OWNCLOUD_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Owncloud domain" | awk -F ':' '{print $2}')
473 570
         restore_database_from_friend owncloud $OWNCLOUD_DOMAIN_NAME
@@ -499,6 +596,11 @@ function restore_owncloud {
499 596
 }
500 597
 
501 598
 function restore_gogs {
599
+    if [[ $RESTORE_APP != 'all' ]]; then
600
+        if [[ $RESTORE_APP != 'gogs' ]]; then
601
+            return
602
+        fi
603
+    fi
502 604
     if grep -q "Gogs domain" $COMPLETION_FILE; then
503 605
         GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}')
504 606
         restore_database_from_friend gogs $GIT_DOMAIN_NAME
@@ -534,6 +636,11 @@ function restore_gogs {
534 636
 }
535 637
 
536 638
 function restore_wiki {
639
+    if [[ $RESTORE_APP != 'all' ]]; then
640
+        if [[ $RESTORE_APP != 'wiki' ]]; then
641
+            return
642
+        fi
643
+    fi
537 644
     if [ -d $SERVER_DIRECTORY/backup/wiki ]; then
538 645
         WIKI_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Wiki domain" | awk -F ':' '{print $2}')
539 646
         echo $"Restoring Wiki installation $WIKI_DOMAIN_NAME"
@@ -562,6 +669,11 @@ function restore_wiki {
562 669
 }
563 670
 
564 671
 function restore_blog {
672
+    if [[ $RESTORE_APP != 'all' ]]; then
673
+        if [[ $RESTORE_APP != 'blog' ]]; then
674
+            return
675
+        fi
676
+    fi
565 677
     if [ -d $SERVER_DIRECTORY/backup/blog ]; then
566 678
         FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
567 679
         echo $"Restoring blog installation $FULLBLOG_DOMAIN_NAME"
@@ -596,6 +708,11 @@ function restore_blog {
596 708
 }
597 709
 
598 710
 function restore_cjdns {
711
+    if [[ $RESTORE_APP != 'all' ]]; then
712
+        if [[ $RESTORE_APP != 'cjdns' ]]; then
713
+            return
714
+        fi
715
+    fi
599 716
     if [ -d $SERVER_DIRECTORY/backup/cjdns ]; then
600 717
         echo $"Restoring cjdns installation"
601 718
         restore_directory_from_friend /root/tempcjdns cjdns
@@ -609,6 +726,11 @@ function restore_cjdns {
609 726
 }
610 727
 
611 728
 function restore_voip {
729
+    if [[ $RESTORE_APP != 'all' ]]; then
730
+        if [[ $RESTORE_APP != 'voip' ]]; then
731
+            return
732
+        fi
733
+    fi
612 734
     if [ -d $SERVER_DIRECTORY/backup/voip ]; then
613 735
         echo $"Restoring VoIP settings"
614 736
         restore_directory_from_friend /root/tempvoip voip
@@ -637,6 +759,11 @@ function restore_voip {
637 759
 }
638 760
 
639 761
 function restore_tox {
762
+    if [[ $RESTORE_APP != 'all' ]]; then
763
+        if [[ $RESTORE_APP != 'tox' ]]; then
764
+            return
765
+        fi
766
+    fi
640 767
     if [ -d $SERVER_DIRECTORY/backup/tox ]; then
641 768
         echo $"Restoring Tox node settings"
642 769
         restore_directory_from_friend / tox
@@ -653,6 +780,11 @@ function restore_tox {
653 780
 }
654 781
 
655 782
 function restore_email {
783
+    if [[ $RESTORE_APP != 'all' ]]; then
784
+        if [[ $RESTORE_APP != 'email' ]]; then
785
+            return
786
+        fi
787
+    fi
656 788
     for d in $SERVER_DIRECTORY/backup/mail/*/ ; do
657 789
         USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
658 790
         if [[ $USERNAME != "git" ]]; then
@@ -676,6 +808,11 @@ function restore_email {
676 808
 }
677 809
 
678 810
 function restore_dlna {
811
+    if [[ $RESTORE_APP != 'all' ]]; then
812
+        if [[ $RESTORE_APP != 'dlna' ]]; then
813
+            return
814
+        fi
815
+    fi
679 816
     if [ -d /var/cache/minidlna ]; then
680 817
         if [ -d $SERVER_DIRECTORY/backup/dlna ]; then
681 818
             echo $"Restoring DLNA cache"