Browse Source

Backup and restore fin files if they exist

Bob Mottram 9 years ago
parent
commit
0e247a521c

+ 28
- 22
src/freedombone-backup-local View File

@@ -289,6 +289,12 @@ function backup_users {
289 289
                 backup_directory_to_usb /home/$USERNAME/.ssh ssh/$USERNAME
290 290
             fi
291 291
 
292
+            # Backup fin database if it exists
293
+            if [ -d /home/$USERNAME/.fin ]; then
294
+                echo $"Backing up fin files for $USERNAME"
295
+                backup_directory_to_usb /home/$USERNAME/.fin fin/$USERNAME
296
+            fi
297
+
292 298
             # Backup user configs
293 299
             if [ -d /home/$USERNAME/.config ]; then
294 300
                 echo $"Backing up config files for $USERNAME"
@@ -506,28 +512,28 @@ function valid_backup_destination {
506 512
     is_valid="yes"
507 513
 
508 514
     if [[ "$destination_dir" == "hubzilla" || \
509
-          "$destination_dir" == "hubzilladata" || \
510
-          "$destination_dir" == "gogs" || \
511
-          "$destination_dir" == "gogsrepos" || \
512
-          "$destination_dir" == "gogsssh" || \
513
-          "$destination_dir" == "gnusocial" || \
514
-          "$destination_dir" == "gnusocialdata" || \
515
-          "$destination_dir" == "mariadb" || \
516
-          "$destination_dir" == "config" || \
517
-          "$destination_dir" == "letsencrypt" || \
518
-          "$destination_dir" == "wiki" || \
519
-          "$destination_dir" == "wiki2" || \
520
-          "$destination_dir" == "xmpp" || \
521
-          "$destination_dir" == "ipfs" || \
522
-          "$destination_dir" == "dlna" || \
523
-          "$destination_dir" == "tox" || \
524
-          "$destination_dir" == "ssl" || \
525
-          "$destination_dir" == "ttrss" || \
526
-          "$destination_dir" == "blog" || \
527
-          "$destination_dir" == "owncloud" || \
528
-          "$destination_dir" == "owncloud2" || \
529
-          "$destination_dir" == "ownclouddata" || \
530
-          "$destination_dir" == "mailinglist" ]]; then
515
+				"$destination_dir" == "hubzilladata" || \
516
+				"$destination_dir" == "gogs" || \
517
+				"$destination_dir" == "gogsrepos" || \
518
+				"$destination_dir" == "gogsssh" || \
519
+				"$destination_dir" == "gnusocial" || \
520
+				"$destination_dir" == "gnusocialdata" || \
521
+				"$destination_dir" == "mariadb" || \
522
+				"$destination_dir" == "config" || \
523
+				"$destination_dir" == "letsencrypt" || \
524
+				"$destination_dir" == "wiki" || \
525
+				"$destination_dir" == "wiki2" || \
526
+				"$destination_dir" == "xmpp" || \
527
+				"$destination_dir" == "ipfs" || \
528
+				"$destination_dir" == "dlna" || \
529
+				"$destination_dir" == "tox" || \
530
+				"$destination_dir" == "ssl" || \
531
+				"$destination_dir" == "ttrss" || \
532
+				"$destination_dir" == "blog" || \
533
+				"$destination_dir" == "owncloud" || \
534
+				"$destination_dir" == "owncloud2" || \
535
+				"$destination_dir" == "ownclouddata" || \
536
+				"$destination_dir" == "mailinglist" ]]; then
531 537
         is_valid="no"
532 538
     fi
533 539
 

+ 28
- 22
src/freedombone-backup-remote View File

@@ -208,6 +208,12 @@ function backup_users {
208 208
                 backup_directory_to_friend /home/$USERNAME/.config config/$USERNAME
209 209
             fi
210 210
 
211
+            # fin files
212
+            if [ -d /home/$USERNAME/.fin ]; then
213
+                echo $"Backing up fin files for $USERNAME"
214
+                backup_directory_to_friend /home/$USERNAME/.fin fin/$USERNAME
215
+            fi
216
+
211 217
             # local files
212 218
             if [ -d /home/$USERNAME/.local ]; then
213 219
                 echo $"Backing up local files for $USERNAME"
@@ -507,7 +513,7 @@ function disperse_key_shares {
507 513
 
508 514
                 # copy the fragments directory to the remote server
509 515
                 /usr/bin/sshpass -p "$REMOTE_PASSWORD" \
510
-                    scp -r -P $REMOTE_SSH_PORT $temp_key_share_fragments $REMOTE_SERVER
516
+                                 scp -r -P $REMOTE_SSH_PORT $temp_key_share_fragments $REMOTE_SERVER
511 517
                 if [ ! "$?" = "0" ]; then
512 518
                     # Send a warning email
513 519
                     echo "Key share to $REMOTE_SERVER failed" | \
@@ -531,27 +537,27 @@ function valid_backup_destination {
531 537
     is_valid="yes"
532 538
 
533 539
     if [[ "$destination_dir" == "hubzilla" || \
534
-          "$destination_dir" == "hubzilladata" || \
535
-          "$destination_dir" == "gogs" || \
536
-          "$destination_dir" == "gogsrepos" || \
537
-          "$destination_dir" == "gogsssh" || \
538
-          "$destination_dir" == "gnusocial" || \
539
-          "$destination_dir" == "gnusocialdata" || \
540
-          "$destination_dir" == "mariadb" || \
541
-          "$destination_dir" == "config" || \
542
-          "$destination_dir" == "letsencrypt" || \
543
-          "$destination_dir" == "wiki" || \
544
-          "$destination_dir" == "wiki2" || \
545
-          "$destination_dir" == "xmpp" || \
546
-          "$destination_dir" == "ipfs" || \
547
-          "$destination_dir" == "dlna" || \
548
-          "$destination_dir" == "tox" || \
549
-          "$destination_dir" == "ssl" || \
550
-          "$destination_dir" == "blog" || \
551
-          "$destination_dir" == "owncloud" || \
552
-          "$destination_dir" == "owncloud2" || \
553
-          "$destination_dir" == "ownclouddata" || \
554
-          "$destination_dir" == "mailinglist" ]]; then
540
+                "$destination_dir" == "hubzilladata" || \
541
+                "$destination_dir" == "gogs" || \
542
+                "$destination_dir" == "gogsrepos" || \
543
+                "$destination_dir" == "gogsssh" || \
544
+                "$destination_dir" == "gnusocial" || \
545
+                "$destination_dir" == "gnusocialdata" || \
546
+                "$destination_dir" == "mariadb" || \
547
+                "$destination_dir" == "config" || \
548
+                "$destination_dir" == "letsencrypt" || \
549
+                "$destination_dir" == "wiki" || \
550
+                "$destination_dir" == "wiki2" || \
551
+                "$destination_dir" == "xmpp" || \
552
+                "$destination_dir" == "ipfs" || \
553
+                "$destination_dir" == "dlna" || \
554
+                "$destination_dir" == "tox" || \
555
+                "$destination_dir" == "ssl" || \
556
+                "$destination_dir" == "blog" || \
557
+                "$destination_dir" == "owncloud" || \
558
+                "$destination_dir" == "owncloud2" || \
559
+                "$destination_dir" == "ownclouddata" || \
560
+                "$destination_dir" == "mailinglist" ]]; then
555 561
         is_valid="no"
556 562
     fi
557 563
 

+ 28
- 0
src/freedombone-restore-local View File

@@ -601,6 +601,33 @@ function restore_user_config {
601 601
     fi
602 602
 }
603 603
 
604
+function restore_user_fin {
605
+    if [[ $RESTORE_APP != 'all' ]]; then
606
+        if [[ $RESTORE_APP != 'userfin' ]]; then
607
+            return
608
+        fi
609
+    fi
610
+    if [ -d $USB_MOUNT/backup/fin ]; then
611
+        for d in $USB_MOUNT/backup/fin/*/ ; do
612
+            USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
613
+            if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
614
+                if [ ! -d /home/$USERNAME ]; then
615
+                    ${PROJECT_NAME}-adduser $USERNAME
616
+                fi
617
+                echo $"Restoring fin files for $USERNAME"
618
+                restore_directory_from_usb /root/tempfin fin/$USERNAME
619
+                cp -r /root/tempfin/home/$USERNAME/.fin /home/$USERNAME/
620
+                if [ ! "$?" = "0" ]; then
621
+                    rm -rf /root/tempfin
622
+                    unmount_drive
623
+                    exit 664
624
+                fi
625
+                rm -rf /root/tempfin
626
+            fi
627
+        done
628
+    fi
629
+}
630
+
604 631
 function restore_user_local {
605 632
     if [[ $RESTORE_APP != 'all' ]]; then
606 633
         if [[ $RESTORE_APP != 'userlocal' ]]; then
@@ -1097,6 +1124,7 @@ restore_admin_readme
1097 1124
 restore_ipfs
1098 1125
 restore_user_ssh_keys
1099 1126
 restore_user_config
1127
+restore_user_fin
1100 1128
 restore_user_local
1101 1129
 restore_certs
1102 1130
 restore_personal_settings

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

@@ -481,6 +481,32 @@ function restore_user_config {
481 481
     done
482 482
 }
483 483
 
484
+function restore_user_fin {
485
+    if [[ $RESTORE_APP != 'all' ]]; then
486
+        if [[ $RESTORE_APP != 'userfin' ]]; then
487
+            return
488
+        fi
489
+    fi
490
+    for d in $SERVER_DIRECTORY/backup/fin/*/ ; do
491
+        USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
492
+        if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
493
+            if [ -d $SERVER_DIRECTORY/backup/fin/$USERNAME ]; then
494
+                if [ ! -d /home/$USERNAME ]; then
495
+                    ${PROJECT_NAME}-adduser $USERNAME
496
+                fi
497
+                echo $"Restoring fin files for $USERNAME"
498
+                restore_directory_from_friend /root/tempfin fin/$USERNAME
499
+                cp -r /root/tempfin/home/$USERNAME/.fin /home/$USERNAME/
500
+                if [ ! "$?" = "0" ]; then
501
+                    rm -rf /root/tempfin
502
+                    exit 664
503
+                fi
504
+                rm -rf /root/tempfin
505
+            fi
506
+        fi
507
+    done
508
+}
509
+
484 510
 function restore_user_local {
485 511
     if [[ $RESTORE_APP != 'all' ]]; then
486 512
         if [[ $RESTORE_APP != 'userlocal' ]]; then
@@ -950,6 +976,7 @@ restore_admin_readme
950 976
 restore_ipfs
951 977
 restore_ssh_keys
952 978
 restore_user_config
979
+restore_user_fin
953 980
 restore_user_local
954 981
 restore_certs
955 982
 restore_personal_settings