Parcourir la source

Prepare for the return of duplicity

Bob Mottram il y a 7 ans
Parent
révision
53ca037736

+ 4
- 3
src/freedombone-image-customise Voir le fichier

@@ -1065,8 +1065,9 @@ function image_setup_utils {
1065 1065
     rm $rootdir/root/sysctl.conf
1066 1066
 
1067 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 1071
     chroot "$rootdir" apt-get -yq install sudo git dialog build-essential avahi-daemon avahi-utils
1071 1072
     chroot "$rootdir" apt-get -yq install avahi-discover avahi-autoipd iptables dnsutils net-tools
1072 1073
     chroot "$rootdir" apt-get -yq install network-manager iputils-ping libnss-mdns libnss-myhostname
@@ -1166,7 +1167,7 @@ function image_setup_utils {
1166 1167
     chroot "$rootdir" apt-get -yq install dovecot-imapd
1167 1168
 
1168 1169
     #backup
1169
-    chroot "$rootdir" apt-get -yq install obnam gnupg
1170
+    chroot "$rootdir" apt-get -yq install obnam duplicity gnupg
1170 1171
 
1171 1172
     # monkeysphere
1172 1173
     #chroot "$rootdir" apt-get -yq install monkeysphere msva-perl

+ 109
- 43
src/freedombone-utils-backup Voir le fichier

@@ -247,6 +247,56 @@ function set_obnam_client_name {
247 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 300
 function backup_directory_to_usb {
251 301
     if [ ! -d ${1} ]; then
252 302
         echo $"WARNING: directory does not exist: ${1}"
@@ -263,35 +313,10 @@ function backup_directory_to_usb {
263 313
         if [ ! -d $USB_MOUNT/backup/${2} ]; then
264 314
             mkdir -p $USB_MOUNT/backup/${2}
265 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 320
         if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
296 321
             shred -zu ${1}/*
297 322
             rm -rf ${1}
@@ -299,6 +324,15 @@ function backup_directory_to_usb {
299 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 336
 function restore_directory_from_usb {
303 337
     if [ ! ${1} ]; then
304 338
         echo "obnam restore -r $USB_MOUNT/backup/${2} --to ${1}"
@@ -313,8 +347,17 @@ function restore_directory_from_usb {
313 347
     if [ ! -d ${1} ]; then
314 348
         mkdir ${1}
315 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 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 363
 function restore_directory_from_friend {
@@ -331,8 +374,8 @@ function restore_directory_from_friend {
331 374
     if [ ! -d ${1} ]; then
332 375
         mkdir ${1}
333 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 381
 function backup_database_to_usb {
@@ -357,19 +400,23 @@ function set_user_permissions {
357 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 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 420
     set_obnam_client_name
374 421
     echo "$BACKUP_DUMMY_PASSWORD" | obnam force-lock -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID} ${1}
375 422
     echo "$BACKUP_DUMMY_PASSWORD" | obnam backup -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID} ${1}
@@ -399,6 +446,25 @@ function backup_directory_to_friend {
399 446
         restart_site
400 447
         exit 853
401 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 468
     if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
403 469
         shred -zu /root/temp${2}/*
404 470
         rm -rf /root/temp${2}

+ 1
- 2
src/freedombone-utils-guile Voir le fichier

@@ -45,11 +45,10 @@ function install_8sync {
45 45
     git_clone $EIGHTSYNC_REPO $INSTALL_DIR/eightsync
46 46
     cd $INSTALL_DIR/eightsync
47 47
     git checkout ${EIGHTSYNC_COMMIT} -b ${EIGHTSYNC_COMMIT}
48
-    #GUILE_PATH=/opt/guile-${GUILE_VERSION}
48
+
49 49
     export GUILE_BASE_PATH=/opt/guile-${GUILE_VERSION}
50 50
     export GUILE_CFLAGS="-I${GUILE_BASE_PATH}/include"
51 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 52
     ./bootstrap.sh
54 53
     configure
55 54
     make

+ 1
- 1
src/freedombone-utils-setup Voir le fichier

@@ -260,7 +260,7 @@ function initial_setup {
260 260
     apt-get -yq dist-upgrade
261 261
     apt-get -yq install ca-certificates
262 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 264
     apt-get -yq install avahi-utils avahi-discover connect-proxy openssh-server
265 265
     apt-get -yq install sudo git dialog build-essential avahi-daemon avahi-utils
266 266
     apt-get -yq install avahi-discover avahi-autoipd iptables dnsutils net-tools