|
@@ -55,10 +55,89 @@ function backup_local_syncthing {
|
55
|
55
|
fi
|
56
|
56
|
}
|
57
|
57
|
|
|
58
|
+function restore_local_syncthing {
|
|
59
|
+ if [ -f /etc/systemd/system/syncthing.service ]; then
|
|
60
|
+ systemctl stop syncthing
|
|
61
|
+ systemctl stop cron
|
|
62
|
+ fi
|
|
63
|
+
|
|
64
|
+ temp_restore_dir=/root/tempsyncthing
|
|
65
|
+ if [ -d $USB_MOUNT/backup/syncthingconfig ]; then
|
|
66
|
+ echo $"Restoring syncthing configuration"
|
|
67
|
+ function_check restore_directory_from_usb
|
|
68
|
+ restore_directory_from_usb ${temp_restore_dir}config syncthingconfig
|
|
69
|
+ cp -r ${temp_restore_dir}config/* /
|
|
70
|
+ if [ ! "$?" = "0" ]; then
|
|
71
|
+ set_user_permissions
|
|
72
|
+ backup_unmount_drive
|
|
73
|
+ systemctl start syncthing
|
|
74
|
+ systemctl start cron
|
|
75
|
+ exit 6833
|
|
76
|
+ fi
|
|
77
|
+ rm -rf ${temp_restore_dir}config
|
|
78
|
+ fi
|
|
79
|
+
|
|
80
|
+ if [ -d $USB_MOUNT/backup/syncthingshared ]; then
|
|
81
|
+ echo $"Restoring syncthing shared files"
|
|
82
|
+ restore_directory_from_usb ${temp_restore_dir}shared syncthingshared
|
|
83
|
+ cp -r ${temp_restore_dir}shared/* /
|
|
84
|
+ if [ ! "$?" = "0" ]; then
|
|
85
|
+ set_user_permissions
|
|
86
|
+ backup_unmount_drive
|
|
87
|
+ systemctl start syncthing
|
|
88
|
+ systemctl start cron
|
|
89
|
+ exit 37904
|
|
90
|
+ fi
|
|
91
|
+ rm -rf ${temp_restore_dir}shared
|
|
92
|
+ fi
|
|
93
|
+
|
|
94
|
+ if [ -d $USB_MOUNT/backup/syncthing ]; then
|
|
95
|
+ for d in $USB_MOUNT/backup/syncthing/*/ ; do
|
|
96
|
+ USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
|
|
97
|
+ if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
|
|
98
|
+ if [ ! -d /home/$USERNAME ]; then
|
|
99
|
+ ${PROJECT_NAME}-adduser $USERNAME
|
|
100
|
+ fi
|
|
101
|
+ echo $"Restoring syncthing files for $USERNAME"
|
|
102
|
+ restore_directory_from_usb ${temp_restore_dir} syncthing/$USERNAME
|
|
103
|
+ cp -r ${temp_restore_dir}/home/$USERNAME/Sync /home/$USERNAME/
|
|
104
|
+ if [ ! "$?" = "0" ]; then
|
|
105
|
+ rm -rf ${temp_restore_dir}
|
|
106
|
+ set_user_permissions
|
|
107
|
+ backup_unmount_drive
|
|
108
|
+ systemctl start syncthing
|
|
109
|
+ systemctl start cron
|
|
110
|
+ exit 68438
|
|
111
|
+ fi
|
|
112
|
+ rm -rf ${temp_restore_dir}
|
|
113
|
+
|
|
114
|
+ # restore device IDs from config settings
|
|
115
|
+ if [ -f /home/$USERNAME/.config/syncthing/.syncthing-server-id ]; then
|
|
116
|
+ cp /home/$USERNAME/.config/syncthing/.syncthing-server-id /home/$USERNAME/.syncthing-server-id
|
|
117
|
+ chown $USERNAME:$USERNAME /home/$USERNAME/.syncthing-server-id
|
|
118
|
+ fi
|
|
119
|
+ if [ -f /home/$USERNAME/.config/syncthing/.syncthingids ]; then
|
|
120
|
+ cp /home/$USERNAME/.config/syncthing/.syncthingids /home/$USERNAME/.syncthingids
|
|
121
|
+ chown $USERNAME:$USERNAME /home/$USERNAME/.syncthingids
|
|
122
|
+ fi
|
|
123
|
+ fi
|
|
124
|
+ done
|
|
125
|
+ fi
|
|
126
|
+
|
|
127
|
+ if [ -f /etc/systemd/system/syncthing.service ]; then
|
|
128
|
+ systemctl start syncthing
|
|
129
|
+ systemctl start cron
|
|
130
|
+ fi
|
|
131
|
+}
|
|
132
|
+
|
58
|
133
|
function backup_remote_syncthing {
|
59
|
134
|
echo -n ''
|
60
|
135
|
}
|
61
|
136
|
|
|
137
|
+function restore_remote_syncthing {
|
|
138
|
+ echo -n ''
|
|
139
|
+}
|
|
140
|
+
|
62
|
141
|
function remove_syncthing {
|
63
|
142
|
if ! grep -Fxq "install_syncthing" $COMPLETION_FILE; then
|
64
|
143
|
return
|