浏览代码

Move syncthing users backup to app script

Bob Mottram 8 年前
父节点
当前提交
6afd2ddf42
共有 2 个文件被更改,包括 46 次插入19 次删除
  1. 46
    0
      src/freedombone-app-syncthing
  2. 0
    19
      src/freedombone-backup-local

+ 46
- 0
src/freedombone-app-syncthing 查看文件

237
 
237
 
238
         echo $"Backup to syncthing complete"
238
         echo $"Backup to syncthing complete"
239
     fi
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
 function restore_local_syncthing {
265
 function restore_local_syncthing {
327
         backup_directory_to_friend /var/lib/syncthing/SyncShared syncthingshared
350
         backup_directory_to_friend /var/lib/syncthing/SyncShared syncthingshared
328
         echo $"Backup of syncthing shared files complete"
351
         echo $"Backup of syncthing shared files complete"
329
     fi
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
 function restore_remote_syncthing {
378
 function restore_remote_syncthing {

+ 0
- 19
src/freedombone-backup-local 查看文件

124
                 backup_directory_to_usb /home/$USERNAME/.fin fin/$USERNAME
124
                 backup_directory_to_usb /home/$USERNAME/.fin fin/$USERNAME
125
             fi
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
             # Backup emacs
127
             # Backup emacs
147
             if [ -d /home/$USERNAME/.emacs.d ]; then
128
             if [ -d /home/$USERNAME/.emacs.d ]; then
148
                 echo $"Backing up Emacs config for $USERNAME"
129
                 echo $"Backing up Emacs config for $USERNAME"