Kaynağa Gözat

Move syncthing users backup to app script

Bob Mottram 8 yıl önce
ebeveyn
işleme
6afd2ddf42
2 değiştirilmiş dosya ile 46 ekleme ve 19 silme
  1. 46
    0
      src/freedombone-app-syncthing
  2. 0
    19
      src/freedombone-backup-local

+ 46
- 0
src/freedombone-app-syncthing Dosyayı Görüntüle

@@ -237,6 +237,29 @@ function backup_local_syncthing {
237 237
 
238 238
         echo $"Backup to syncthing complete"
239 239
     fi
240
+
241
+    for d in /home/*/ ; do
242
+        USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
243
+        if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
244
+            if [ -d /home/$USERNAME/Sync ]; then
245
+                echo $"Backing up syncthing files for $USERNAME"
246
+                backup_directory_to_usb /home/$USERNAME/Sync syncthing/$USERNAME
247
+                # ensure that device IDs will be backed up as part of user config settings
248
+                if [ ! -d /home/$USERNAME/.config/syncthing ]; then
249
+                    mkdir -p /home/$USERNAME/.config/syncthing
250
+                    chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
251
+                fi
252
+                if [ -f /home/$USERNAME/.syncthing-server-id ]; then
253
+                    cp /home/$USERNAME/.syncthing-server-id /home/$USERNAME/.config/syncthing
254
+                    chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
255
+                fi
256
+                if [ -f /home/$USERNAME/.syncthingids ]; then
257
+                    cp /home/$USERNAME/.syncthingids /home/$USERNAME/.config/syncthing
258
+                    chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
259
+                fi
260
+            fi
261
+        fi
262
+    done
240 263
 }
241 264
 
242 265
 function restore_local_syncthing {
@@ -327,6 +350,29 @@ function backup_remote_syncthing {
327 350
         backup_directory_to_friend /var/lib/syncthing/SyncShared syncthingshared
328 351
         echo $"Backup of syncthing shared files complete"
329 352
     fi
353
+
354
+    for d in /home/*/ ; do
355
+        USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
356
+        if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
357
+            if [ -d /home/$USERNAME/Sync ]; then
358
+                echo $"Backing up syncthing files for $USERNAME"
359
+                backup_directory_to_friend /home/$USERNAME/Sync syncthing/$USERNAME
360
+                # ensure that device IDs will be backed up as part of user config settings
361
+                if [ ! -d /home/$USERNAME/.config/syncthing ]; then
362
+                    mkdir -p /home/$USERNAME/.config/syncthing
363
+                    chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
364
+                fi
365
+                if [ -f /home/$USERNAME/.syncthing-server-id ]; then
366
+                    cp /home/$USERNAME/.syncthing-server-id /home/$USERNAME/.config/syncthing
367
+                    chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
368
+                fi
369
+                if [ -f /home/$USERNAME/.syncthingids ]; then
370
+                    cp /home/$USERNAME/.syncthingids /home/$USERNAME/.config/syncthing
371
+                    chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
372
+                fi
373
+            fi
374
+        fi
375
+    done
330 376
 }
331 377
 
332 378
 function restore_remote_syncthing {

+ 0
- 19
src/freedombone-backup-local Dosyayı Görüntüle

@@ -124,25 +124,6 @@ function backup_users {
124 124
                 backup_directory_to_usb /home/$USERNAME/.fin fin/$USERNAME
125 125
             fi
126 126
 
127
-            # Backup syncthing
128
-            if [ -d /home/$USERNAME/Sync ]; then
129
-                echo $"Backing up syncthing files for $USERNAME"
130
-                backup_directory_to_usb /home/$USERNAME/Sync syncthing/$USERNAME
131
-                # ensure that device IDs will be backed up as part of user config settings
132
-                if [ ! -d /home/$USERNAME/.config/syncthing ]; then
133
-                    mkdir -p /home/$USERNAME/.config/syncthing
134
-                    chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
135
-                fi
136
-                if [ -f /home/$USERNAME/.syncthing-server-id ]; then
137
-                    cp /home/$USERNAME/.syncthing-server-id /home/$USERNAME/.config/syncthing
138
-                    chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
139
-                fi
140
-                if [ -f /home/$USERNAME/.syncthingids ]; then
141
-                    cp /home/$USERNAME/.syncthingids /home/$USERNAME/.config/syncthing
142
-                    chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
143
-                fi
144
-            fi
145
-
146 127
             # Backup emacs
147 128
             if [ -d /home/$USERNAME/.emacs.d ]; then
148 129
                 echo $"Backing up Emacs config for $USERNAME"