浏览代码

Prepare for the return of duplicity

Bob Mottram 7 年前
父节点
当前提交
53ca037736
共有 4 个文件被更改,包括 115 次插入49 次删除
  1. 4
    3
      src/freedombone-image-customise
  2. 109
    43
      src/freedombone-utils-backup
  3. 1
    2
      src/freedombone-utils-guile
  4. 1
    1
      src/freedombone-utils-setup

+ 4
- 3
src/freedombone-image-customise 查看文件

1065
     rm $rootdir/root/sysctl.conf
1065
     rm $rootdir/root/sysctl.conf
1066
 
1066
 
1067
     # all the packages
1067
     # all the packages
1068
-    chroot "$rootdir" apt-get -yq install cryptsetup libgfshare-bin obnam sshpass wget avahi-daemon
1069
-    chroot "$rootdir" apt-get -yq install avahi-utils avahi-discover connect-proxy openssh-server
1068
+    chroot "$rootdir" apt-get -yq install cryptsetup libgfshare-bin obnam duplicity sshpass wget
1069
+    chroot "$rootdir" apt-get -yq install avahi-daemon avahi-utils avahi-discover
1070
+    chroot "$rootdir" apt-get -yq install connect-proxy openssh-server
1070
     chroot "$rootdir" apt-get -yq install sudo git dialog build-essential avahi-daemon avahi-utils
1071
     chroot "$rootdir" apt-get -yq install sudo git dialog build-essential avahi-daemon avahi-utils
1071
     chroot "$rootdir" apt-get -yq install avahi-discover avahi-autoipd iptables dnsutils net-tools
1072
     chroot "$rootdir" apt-get -yq install avahi-discover avahi-autoipd iptables dnsutils net-tools
1072
     chroot "$rootdir" apt-get -yq install network-manager iputils-ping libnss-mdns libnss-myhostname
1073
     chroot "$rootdir" apt-get -yq install network-manager iputils-ping libnss-mdns libnss-myhostname
1166
     chroot "$rootdir" apt-get -yq install dovecot-imapd
1167
     chroot "$rootdir" apt-get -yq install dovecot-imapd
1167
 
1168
 
1168
     #backup
1169
     #backup
1169
-    chroot "$rootdir" apt-get -yq install obnam gnupg
1170
+    chroot "$rootdir" apt-get -yq install obnam duplicity gnupg
1170
 
1171
 
1171
     # monkeysphere
1172
     # monkeysphere
1172
     #chroot "$rootdir" apt-get -yq install monkeysphere msva-perl
1173
     #chroot "$rootdir" apt-get -yq install monkeysphere msva-perl

+ 109
- 43
src/freedombone-utils-backup 查看文件

247
     echo "client-name = ${PROJECT_NAME}" >> /etc/obnam.conf
247
     echo "client-name = ${PROJECT_NAME}" >> /etc/obnam.conf
248
 }
248
 }
249
 
249
 
250
+function backup_directory_to_usb_duplicity {
251
+    echo "$BACKUP_DUMMY_PASSWORD" | duplicity full --encrypt-key $MY_BACKUP_KEY_ID --full-if-older-than 4W --exclude-other-filesystems ${1} file://$USB_MOUNT/backup/${2}
252
+    if [[ $ENABLE_BACKUP_VERIFICATION == "yes" ]]; then
253
+        echo "$BACKUP_DUMMY_PASSWORD" | duplicity verify --encrypt-key $MY_BACKUP_KEY_ID --full-if-older-than 4W --exclude-other-filesystems ${1} file://$USB_MOUNT/backup/${2}
254
+        if [ ! "$?" = "0" ]; then
255
+            umount $USB_MOUNT
256
+            rm -rf $USB_MOUNT
257
+            if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
258
+                shred -zu ${1}/*
259
+                rm -rf ${1}
260
+            fi
261
+            function_check restart_site
262
+            restart_site
263
+            exit 683252
264
+        fi
265
+    fi
266
+}
267
+
268
+function backup_directory_to_usb_obnam {
269
+    set_obnam_client_name
270
+    echo "$BACKUP_DUMMY_PASSWORD" | obnam force-lock -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
271
+    echo "$BACKUP_DUMMY_PASSWORD" | obnam backup -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
272
+    if [[ $ENABLE_BACKUP_VERIFICATION == "yes" ]]; then
273
+        echo "$BACKUP_DUMMY_PASSWORD" | obnam verify -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
274
+        if [ ! "$?" = "0" ]; then
275
+            umount $USB_MOUNT
276
+            rm -rf $USB_MOUNT
277
+            if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
278
+                shred -zu ${1}/*
279
+                rm -rf ${1}
280
+            fi
281
+            function_check restart_site
282
+            restart_site
283
+            exit 683252
284
+        fi
285
+    fi
286
+    echo "$BACKUP_DUMMY_PASSWORD" | obnam forget --keep=30d -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID
287
+    if [ ! "$?" = "0" ]; then
288
+        umount $USB_MOUNT
289
+        rm -rf $USB_MOUNT
290
+        if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
291
+            shred -zu ${1}/*
292
+            rm -rf ${1}
293
+        fi
294
+        function_check restart_site
295
+        restart_site
296
+        exit 7
297
+    fi
298
+}
299
+
250
 function backup_directory_to_usb {
300
 function backup_directory_to_usb {
251
     if [ ! -d ${1} ]; then
301
     if [ ! -d ${1} ]; then
252
         echo $"WARNING: directory does not exist: ${1}"
302
         echo $"WARNING: directory does not exist: ${1}"
263
         if [ ! -d $USB_MOUNT/backup/${2} ]; then
313
         if [ ! -d $USB_MOUNT/backup/${2} ]; then
264
             mkdir -p $USB_MOUNT/backup/${2}
314
             mkdir -p $USB_MOUNT/backup/${2}
265
         fi
315
         fi
266
-        set_obnam_client_name
267
-        echo "$BACKUP_DUMMY_PASSWORD" | obnam force-lock -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
268
-        echo "$BACKUP_DUMMY_PASSWORD" | obnam backup -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
269
-        if [[ $ENABLE_BACKUP_VERIFICATION == "yes" ]]; then
270
-            echo "$BACKUP_DUMMY_PASSWORD" | obnam verify -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
271
-            if [ ! "$?" = "0" ]; then
272
-                umount $USB_MOUNT
273
-                rm -rf $USB_MOUNT
274
-                if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
275
-                    shred -zu ${1}/*
276
-                    rm -rf ${1}
277
-                fi
278
-                function_check restart_site
279
-                restart_site
280
-                exit 683252
281
-            fi
282
-        fi
283
-        echo "$BACKUP_DUMMY_PASSWORD" | obnam forget --keep=30d -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID
284
-        if [ ! "$?" = "0" ]; then
285
-            umount $USB_MOUNT
286
-            rm -rf $USB_MOUNT
287
-            if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
288
-                shred -zu ${1}/*
289
-                rm -rf ${1}
290
-            fi
291
-            function_check restart_site
292
-            restart_site
293
-            exit 7
294
-        fi
316
+
317
+        #backup_directory_to_usb_duplicity ${1} ${2}
318
+        backup_directory_to_usb_obnam ${1} ${2}
319
+
295
         if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
320
         if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
296
             shred -zu ${1}/*
321
             shred -zu ${1}/*
297
             rm -rf ${1}
322
             rm -rf ${1}
299
     fi
324
     fi
300
 }
325
 }
301
 
326
 
327
+function restore_directory_from_usb_obnam {
328
+    set_obnam_client_name
329
+    echo "$BACKUP_DUMMY_PASSWORD" | obnam restore -r $USB_MOUNT/backup/${2} --to ${1}
330
+}
331
+
332
+function restore_directory_from_usb_duplicity {
333
+    echo "$BACKUP_DUMMY_PASSWORD" | duplicity restore --force file://$USB_MOUNT/backup/${2} ${1}
334
+}
335
+
302
 function restore_directory_from_usb {
336
 function restore_directory_from_usb {
303
     if [ ! ${1} ]; then
337
     if [ ! ${1} ]; then
304
         echo "obnam restore -r $USB_MOUNT/backup/${2} --to ${1}"
338
         echo "obnam restore -r $USB_MOUNT/backup/${2} --to ${1}"
313
     if [ ! -d ${1} ]; then
347
     if [ ! -d ${1} ]; then
314
         mkdir ${1}
348
         mkdir ${1}
315
     fi
349
     fi
350
+    #restore_directory_from_usb_duplicity ${1} ${2}
351
+    restore_directory_from_usb_obnam ${1} ${2}
352
+}
353
+
354
+function restore_directory_from_friend_obnam {
316
     set_obnam_client_name
355
     set_obnam_client_name
317
-    echo "$BACKUP_DUMMY_PASSWORD" | obnam restore -r $USB_MOUNT/backup/${2} --to ${1}
356
+    echo "$BACKUP_DUMMY_PASSWORD" | obnam restore -r $SERVER_DIRECTORY/backup/${2} --to ${1}
357
+}
358
+
359
+function restore_directory_from_friend_duplicity {
360
+    echo "$BACKUP_DUMMY_PASSWORD" | duplicity restore --force file://$SERVER_DIRECTORY/backup/${2} ${1}
318
 }
361
 }
319
 
362
 
320
 function restore_directory_from_friend {
363
 function restore_directory_from_friend {
331
     if [ ! -d ${1} ]; then
374
     if [ ! -d ${1} ]; then
332
         mkdir ${1}
375
         mkdir ${1}
333
     fi
376
     fi
334
-    set_obnam_client_name
335
-    echo "$BACKUP_DUMMY_PASSWORD" | obnam restore -r $SERVER_DIRECTORY/backup/${2} --to ${1}
377
+    #restore_directory_from_friend_duplicity ${1} ${2}
378
+    restore_directory_from_friend_obnam ${1} ${2}
336
 }
379
 }
337
 
380
 
338
 function backup_database_to_usb {
381
 function backup_database_to_usb {
357
     done
400
     done
358
 }
401
 }
359
 
402
 
360
-function backup_directory_to_friend {
361
-    BACKUP_KEY_EXISTS=$(gpg --list-keys "$ADMIN_NAME (backup key)")
362
-    if [ ! "$?" = "0" ]; then
363
-        echo $"Backup key could not be found"
364
-        function_check restart_site
365
-        restart_site
366
-        exit 43382
403
+function backup_directory_to_friend_duplicity {
404
+    echo "$BACKUP_DUMMY_PASSWORD" | duplicity full --ssh-askpass --encrypt-key ${ADMIN_BACKUP_KEY_ID} --full-if-older-than 4W --exclude-other-filesystems ${1} $SERVER_DIRECTORY/backup/${2}
405
+    if [[ $ENABLE_BACKUP_VERIFICATION == "yes" ]]; then
406
+        echo "$BACKUP_DUMMY_PASSWORD" | duplicity verify --ssh-askpass --encrypt-key ${ADMIN_BACKUP_KEY_ID} --full-if-older-than 4W --exclude-other-filesystems ${1} $SERVER_DIRECTORY/backup/${2}
407
+        if [ ! "$?" = "0" ]; then
408
+            if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
409
+                shred -zu ${1}/*
410
+                rm -rf ${1}
411
+            fi
412
+            function_check restart_site
413
+            restart_site
414
+            exit 683252
415
+        fi
367
     fi
416
     fi
417
+}
368
 
418
 
369
-    ADMIN_BACKUP_KEY_ID=$(gpg --list-keys "$ADMIN_NAME (backup key)" | sed -n '2p' | sed 's/^[ \t]*//')
370
-    if [ ! -d $SERVER_DIRECTORY/backup/${2} ]; then
371
-        mkdir -p $SERVER_DIRECTORY/backup/${2}
372
-    fi
419
+function backup_directory_to_friend_obnam {
373
     set_obnam_client_name
420
     set_obnam_client_name
374
     echo "$BACKUP_DUMMY_PASSWORD" | obnam force-lock -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID} ${1}
421
     echo "$BACKUP_DUMMY_PASSWORD" | obnam force-lock -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID} ${1}
375
     echo "$BACKUP_DUMMY_PASSWORD" | obnam backup -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID} ${1}
422
     echo "$BACKUP_DUMMY_PASSWORD" | obnam backup -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID} ${1}
399
         restart_site
446
         restart_site
400
         exit 853
447
         exit 853
401
     fi
448
     fi
449
+}
450
+
451
+function backup_directory_to_friend {
452
+    BACKUP_KEY_EXISTS=$(gpg --list-keys "$ADMIN_NAME (backup key)")
453
+    if [ ! "$?" = "0" ]; then
454
+        echo $"Backup key could not be found"
455
+        function_check restart_site
456
+        restart_site
457
+        exit 43382
458
+    fi
459
+
460
+    ADMIN_BACKUP_KEY_ID=$(gpg --list-keys "$ADMIN_NAME (backup key)" | sed -n '2p' | sed 's/^[ \t]*//')
461
+    if [ ! -d $SERVER_DIRECTORY/backup/${2} ]; then
462
+        mkdir -p $SERVER_DIRECTORY/backup/${2}
463
+    fi
464
+
465
+    #backup_directory_to_friend_duplicity ${1} ${2}
466
+    backup_directory_to_friend_obnam ${1} ${2}
467
+
402
     if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
468
     if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
403
         shred -zu /root/temp${2}/*
469
         shred -zu /root/temp${2}/*
404
         rm -rf /root/temp${2}
470
         rm -rf /root/temp${2}

+ 1
- 2
src/freedombone-utils-guile 查看文件

45
     git_clone $EIGHTSYNC_REPO $INSTALL_DIR/eightsync
45
     git_clone $EIGHTSYNC_REPO $INSTALL_DIR/eightsync
46
     cd $INSTALL_DIR/eightsync
46
     cd $INSTALL_DIR/eightsync
47
     git checkout ${EIGHTSYNC_COMMIT} -b ${EIGHTSYNC_COMMIT}
47
     git checkout ${EIGHTSYNC_COMMIT} -b ${EIGHTSYNC_COMMIT}
48
-    #GUILE_PATH=/opt/guile-${GUILE_VERSION}
48
+
49
     export GUILE_BASE_PATH=/opt/guile-${GUILE_VERSION}
49
     export GUILE_BASE_PATH=/opt/guile-${GUILE_VERSION}
50
     export GUILE_CFLAGS="-I${GUILE_BASE_PATH}/include"
50
     export GUILE_CFLAGS="-I${GUILE_BASE_PATH}/include"
51
     export GUILE_LIBS="-L${GUILE_BASE_PATH}/lib -lguile -lqthreads -ldl -ltermcap -lsocket -lnsl -lm"
51
     export GUILE_LIBS="-L${GUILE_BASE_PATH}/lib -lguile -lqthreads -ldl -ltermcap -lsocket -lnsl -lm"
52
-    sed -i '/PKG_CHECK_MODULES/d' configure.ac
53
     ./bootstrap.sh
52
     ./bootstrap.sh
54
     configure
53
     configure
55
     make
54
     make

+ 1
- 1
src/freedombone-utils-setup 查看文件

260
     apt-get -yq dist-upgrade
260
     apt-get -yq dist-upgrade
261
     apt-get -yq install ca-certificates
261
     apt-get -yq install ca-certificates
262
     apt-get -yq install apt-utils
262
     apt-get -yq install apt-utils
263
-    apt-get -yq install cryptsetup libgfshare-bin obnam sshpass wget avahi-daemon
263
+    apt-get -yq install cryptsetup libgfshare-bin obnam duplicity sshpass wget avahi-daemon
264
     apt-get -yq install avahi-utils avahi-discover connect-proxy openssh-server
264
     apt-get -yq install avahi-utils avahi-discover connect-proxy openssh-server
265
     apt-get -yq install sudo git dialog build-essential avahi-daemon avahi-utils
265
     apt-get -yq install sudo git dialog build-essential avahi-daemon avahi-utils
266
     apt-get -yq install avahi-discover avahi-autoipd iptables dnsutils net-tools
266
     apt-get -yq install avahi-discover avahi-autoipd iptables dnsutils net-tools