Sfoglia il codice sorgente

Backup and restore fin files if they exist

Bob Mottram 9 anni fa
parent
commit
0e247a521c

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

289
                 backup_directory_to_usb /home/$USERNAME/.ssh ssh/$USERNAME
289
                 backup_directory_to_usb /home/$USERNAME/.ssh ssh/$USERNAME
290
             fi
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
             # Backup user configs
298
             # Backup user configs
293
             if [ -d /home/$USERNAME/.config ]; then
299
             if [ -d /home/$USERNAME/.config ]; then
294
                 echo $"Backing up config files for $USERNAME"
300
                 echo $"Backing up config files for $USERNAME"
506
     is_valid="yes"
512
     is_valid="yes"
507
 
513
 
508
     if [[ "$destination_dir" == "hubzilla" || \
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
         is_valid="no"
537
         is_valid="no"
532
     fi
538
     fi
533
 
539
 

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

208
                 backup_directory_to_friend /home/$USERNAME/.config config/$USERNAME
208
                 backup_directory_to_friend /home/$USERNAME/.config config/$USERNAME
209
             fi
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
             # local files
217
             # local files
212
             if [ -d /home/$USERNAME/.local ]; then
218
             if [ -d /home/$USERNAME/.local ]; then
213
                 echo $"Backing up local files for $USERNAME"
219
                 echo $"Backing up local files for $USERNAME"
507
 
513
 
508
                 # copy the fragments directory to the remote server
514
                 # copy the fragments directory to the remote server
509
                 /usr/bin/sshpass -p "$REMOTE_PASSWORD" \
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
                 if [ ! "$?" = "0" ]; then
517
                 if [ ! "$?" = "0" ]; then
512
                     # Send a warning email
518
                     # Send a warning email
513
                     echo "Key share to $REMOTE_SERVER failed" | \
519
                     echo "Key share to $REMOTE_SERVER failed" | \
531
     is_valid="yes"
537
     is_valid="yes"
532
 
538
 
533
     if [[ "$destination_dir" == "hubzilla" || \
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
         is_valid="no"
561
         is_valid="no"
556
     fi
562
     fi
557
 
563
 

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

601
     fi
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
 function restore_user_local {
631
 function restore_user_local {
605
     if [[ $RESTORE_APP != 'all' ]]; then
632
     if [[ $RESTORE_APP != 'all' ]]; then
606
         if [[ $RESTORE_APP != 'userlocal' ]]; then
633
         if [[ $RESTORE_APP != 'userlocal' ]]; then
1097
 restore_ipfs
1124
 restore_ipfs
1098
 restore_user_ssh_keys
1125
 restore_user_ssh_keys
1099
 restore_user_config
1126
 restore_user_config
1127
+restore_user_fin
1100
 restore_user_local
1128
 restore_user_local
1101
 restore_certs
1129
 restore_certs
1102
 restore_personal_settings
1130
 restore_personal_settings

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

481
     done
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
 function restore_user_local {
510
 function restore_user_local {
485
     if [[ $RESTORE_APP != 'all' ]]; then
511
     if [[ $RESTORE_APP != 'all' ]]; then
486
         if [[ $RESTORE_APP != 'userlocal' ]]; then
512
         if [[ $RESTORE_APP != 'userlocal' ]]; then
950
 restore_ipfs
976
 restore_ipfs
951
 restore_ssh_keys
977
 restore_ssh_keys
952
 restore_user_config
978
 restore_user_config
979
+restore_user_fin
953
 restore_user_local
980
 restore_user_local
954
 restore_certs
981
 restore_certs
955
 restore_personal_settings
982
 restore_personal_settings