浏览代码

Remote restore of specific applications

Bob Mottram 9 年前
父节点
当前提交
0467fb24f8
共有 3 个文件被更改,包括 137 次插入0 次删除
  1. 二进制
      man/freedombone-restore-local.1.gz
  2. 二进制
      man/freedombone-restore-remote.1.gz
  3. 137
    0
      src/freedombone-restore-remote

二进制
man/freedombone-restore-local.1.gz 查看文件


二进制
man/freedombone-restore-remote.1.gz 查看文件


+ 137
- 0
src/freedombone-restore-remote 查看文件

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