浏览代码

Backup and restore blocklist

Bob Mottram 8 年前
父节点
当前提交
7a222289d0

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

259
     fi
259
     fi
260
 }
260
 }
261
 
261
 
262
+function backup_blocklist {
263
+    if [ ! -f /root/${PROJECT_NAME}-firewall-domains.cfg ]; then
264
+        return
265
+    fi
266
+    echo $"Backing up ${PROJECT_NAME} blocklist"
267
+    temp_backup_dir=/root/tempbackupblocklist
268
+    if [ ! -d $temp_backup_dir ]; then
269
+        mkdir -p $temp_backup_dir
270
+    fi
271
+    if [ -f $NODEJS_INSTALLED_APPS_FILE ]; then
272
+        cp -f /root/${PROJECT_NAME}-firewall-domains.cfg $temp_backup_dir
273
+    fi
274
+    backup_directory_to_usb $temp_backup_dir blocklist
275
+    rm -rf $temp_backup_dir
276
+}
277
+
262
 function backup_configfiles {
278
 function backup_configfiles {
263
     echo $"Backing up ${PROJECT_NAME} configuration files"
279
     echo $"Backing up ${PROJECT_NAME} configuration files"
264
     temp_backup_dir=/root/tempbackupconfig
280
     temp_backup_dir=/root/tempbackupconfig
285
         cp -f /etc/nginx/.htpasswd $temp_backup_dir/htpasswd
301
         cp -f /etc/nginx/.htpasswd $temp_backup_dir/htpasswd
286
     fi
302
     fi
287
     backup_directory_to_usb $temp_backup_dir configfiles
303
     backup_directory_to_usb $temp_backup_dir configfiles
304
+    rm -rf $temp_backup_dir
288
 }
305
 }
289
 
306
 
290
 function backup_admin_readme {
307
 function backup_admin_readme {
335
 backup_directories
352
 backup_directories
336
 backup_apps local
353
 backup_apps local
337
 backup_configfiles
354
 backup_configfiles
355
+backup_blocklist
338
 backup_admin_readme
356
 backup_admin_readme
339
 backup_mariadb
357
 backup_mariadb
340
 backup_extra_directories local
358
 backup_extra_directories local

+ 17
- 0
src/freedombone-backup-remote 查看文件

105
     SUSPENDED_SITE=
105
     SUSPENDED_SITE=
106
 }
106
 }
107
 
107
 
108
+function backup_blocklist {
109
+    if [ ! -f /root/${PROJECT_NAME}-firewall-domains.cfg ]; then
110
+        return
111
+    fi
112
+    echo $"Backing up ${PROJECT_NAME} blocklist"
113
+    temp_backup_dir=/root/tempbackupblocklist
114
+    if [ ! -d $temp_backup_dir ]; then
115
+        mkdir -p $temp_backup_dir
116
+    fi
117
+    if [ -f $NODEJS_INSTALLED_APPS_FILE ]; then
118
+        cp -f /root/${PROJECT_NAME}-firewall-domains.cfg $temp_backup_dir
119
+    fi
120
+    backup_directory_to_friend $temp_backup_dir blocklist
121
+    rm -rf $temp_backup_dir
122
+}
123
+
108
 function backup_configfiles {
124
 function backup_configfiles {
109
     echo $"Backing up ${PROJECT_NAME} configuration files"
125
     echo $"Backing up ${PROJECT_NAME} configuration files"
110
     temp_backup_dir=/root/tempbackupconfig
126
     temp_backup_dir=/root/tempbackupconfig
386
 
402
 
387
 backup_configfiles
403
 backup_configfiles
388
 if [[ $TEST_MODE == "no" ]]; then
404
 if [[ $TEST_MODE == "no" ]]; then
405
+    backup_blocklist
389
     backup_users
406
     backup_users
390
     backup_letsencrypt
407
     backup_letsencrypt
391
     backup_passwordstore
408
     backup_passwordstore

+ 1
- 0
src/freedombone-controlpanel 查看文件

1102
     fi
1102
     fi
1103
 
1103
 
1104
     utils_installed=(configfiles
1104
     utils_installed=(configfiles
1105
+                     blocklist
1105
                      mariadb
1106
                      mariadb
1106
                      letsencrypt
1107
                      letsencrypt
1107
                      passwords
1108
                      passwords

+ 24
- 2
src/freedombone-restore-local 查看文件

111
     gpg_set_permissions root
111
     gpg_set_permissions root
112
 }
112
 }
113
 
113
 
114
+function restore_blocklist {
115
+    if [[ $RESTORE_APP != 'all' ]]; then
116
+        if [[ $RESTORE_APP != 'blocklist' ]]; then
117
+            return
118
+        fi
119
+    fi
120
+
121
+    # this restores *.cfg and COMPLETION_FILE
122
+    if [ -d $USB_MOUNT/backup/blocklist ]; then
123
+        echo $"Restoring blocklist"
124
+        temp_restore_dir=/root/tempblocklist
125
+        restore_directory_from_usb $temp_restore_dir blocklist
126
+
127
+        if [ -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg ]; then
128
+            cp -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg /root/${PROJECT_NAME}-firewall-domains.cfg
129
+        fi
130
+
131
+        rm -rf $temp_restore_dir
132
+    fi
133
+}
134
+
114
 function restore_configfiles {
135
 function restore_configfiles {
115
     if [[ $RESTORE_APP != 'all' ]]; then
136
     if [[ $RESTORE_APP != 'all' ]]; then
116
         if [[ $RESTORE_APP != 'configfiles' ]]; then
137
         if [[ $RESTORE_APP != 'configfiles' ]]; then
119
     fi
140
     fi
120
 
141
 
121
     # this restores *.cfg and COMPLETION_FILE
142
     # this restores *.cfg and COMPLETION_FILE
122
-    if [ -d $USB_MOUNT/backup/config ]; then
143
+    if [ -d $USB_MOUNT/backup/configfiles ]; then
123
         echo $"Restoring configuration files"
144
         echo $"Restoring configuration files"
124
-        temp_restore_dir=/root/tempconfig
145
+        temp_restore_dir=/root/tempconfigfiles
125
         restore_directory_from_usb $temp_restore_dir configfiles
146
         restore_directory_from_usb $temp_restore_dir configfiles
126
 
147
 
127
         if [ -f $temp_restore_dir/root/.nostore ]; then
148
         if [ -f $temp_restore_dir/root/.nostore ]; then
741
 check_backup_exists
762
 check_backup_exists
742
 check_admin_user
763
 check_admin_user
743
 copy_gpg_keys
764
 copy_gpg_keys
765
+restore_blocklist
744
 restore_configfiles
766
 restore_configfiles
745
 same_admin_user
767
 same_admin_user
746
 restore_passwordstore
768
 restore_passwordstore

+ 25
- 2
src/freedombone-restore-remote 查看文件

102
     gpg_set_permissions root
102
     gpg_set_permissions root
103
 }
103
 }
104
 
104
 
105
+function restore_blocklist {
106
+    if [[ $RESTORE_APP != 'all' ]]; then
107
+        if [[ $RESTORE_APP != 'blocklist' ]]; then
108
+            return
109
+        fi
110
+    fi
111
+
112
+    # this restores *.cfg and COMPLETION_FILE
113
+    if [ -d $USB_MOUNT/backup/blocklist ]; then
114
+        echo $"Restoring blocklist"
115
+        temp_restore_dir=/root/tempblocklist
116
+        restore_directory_from_friend $temp_restore_dir blocklist
117
+        restore_directory_from_usb $temp_restore_dir blocklist
118
+
119
+        if [ -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg ]; then
120
+            cp -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg /root/${PROJECT_NAME}-firewall-domains.cfg
121
+        fi
122
+
123
+        rm -rf $temp_restore_dir
124
+    fi
125
+}
126
+
105
 function restore_configfiles {
127
 function restore_configfiles {
106
     if [[ $RESTORE_APP != 'all' ]]; then
128
     if [[ $RESTORE_APP != 'all' ]]; then
107
         if [[ $RESTORE_APP != 'configfiles' ]]; then
129
         if [[ $RESTORE_APP != 'configfiles' ]]; then
108
             return
130
             return
109
         fi
131
         fi
110
     fi
132
     fi
111
-    if [ -d $SERVER_DIRECTORY/backup/config ]; then
133
+    if [ -d $SERVER_DIRECTORY/backup/configfiles ]; then
112
         echo $"Restoring configuration files"
134
         echo $"Restoring configuration files"
113
-        temp_restore_dir=/root/tempconfig
135
+        temp_restore_dir=/root/tempconfigfiles
114
         restore_directory_from_friend $temp_restore_dir configfiles
136
         restore_directory_from_friend $temp_restore_dir configfiles
115
 
137
 
116
         if [ -f $temp_restore_dir/root/.nostore ]; then
138
         if [ -f $temp_restore_dir/root/.nostore ]; then
655
 ${PROJECT_NAME}-recoverkey -u ${ADMIN_USERNAME} -l $BACKUP_LIST
677
 ${PROJECT_NAME}-recoverkey -u ${ADMIN_USERNAME} -l $BACKUP_LIST
656
 
678
 
657
 copy_gpg_keys
679
 copy_gpg_keys
680
+restore_blocklist
658
 restore_configfiles
681
 restore_configfiles
659
 restore_passwordstore
682
 restore_passwordstore
660
 restore_mariadb
683
 restore_mariadb