Browse Source

Check for backup failures

Bob Mottram 7 years ago
parent
commit
09d6beddb2
1 changed files with 22 additions and 0 deletions
  1. 22
    0
      src/freedombone-utils-backup

+ 22
- 0
src/freedombone-utils-backup View File

@@ -264,6 +264,18 @@ function set_obnam_client_name {
264 264
 function backup_directory_to_usb_duplicity {
265 265
     create_backups_temp_directory
266 266
     echo "$BACKUP_DUMMY_PASSWORD" | duplicity full --tempdir $BACKUP_TEMP_DIRECTORY --encrypt-key $MY_BACKUP_KEY_ID --full-if-older-than 4W --exclude-other-filesystems ${1} file://$USB_MOUNT/backup/${2}
267
+    if [ ! "$?" = "0" ]; then
268
+        umount $USB_MOUNT
269
+        rm -rf $USB_MOUNT
270
+        if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
271
+            shred -zu ${1}/*
272
+            rm -rf ${1}
273
+        fi
274
+        function_check restart_site
275
+        restart_site
276
+        remove_backups_temp_directory
277
+        exit 8352925
278
+    fi
267 279
     if [[ $ENABLE_BACKUP_VERIFICATION == "yes" ]]; then
268 280
         echo "$BACKUP_DUMMY_PASSWORD" | duplicity verify --tempdir $BACKUP_TEMP_DIRECTORY --encrypt-key $MY_BACKUP_KEY_ID --full-if-older-than 4W --exclude-other-filesystems ${1} file://$USB_MOUNT/backup/${2}
269 281
         if [ ! "$?" = "0" ]; then
@@ -424,6 +436,16 @@ function set_user_permissions {
424 436
 function backup_directory_to_friend_duplicity {
425 437
     create_backups_temp_directory
426 438
     echo "$BACKUP_DUMMY_PASSWORD" | duplicity full --tempdir $BACKUP_TEMP_DIRECTORY --ssh-askpass --encrypt-key ${ADMIN_BACKUP_KEY_ID} --full-if-older-than 4W --exclude-other-filesystems ${1} $SERVER_DIRECTORY/backup/${2}
439
+    if [ ! "$?" = "0" ]; then
440
+        if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
441
+            shred -zu ${1}/*
442
+            rm -rf ${1}
443
+        fi
444
+        function_check restart_site
445
+        restart_site
446
+        remove_backups_temp_directory
447
+        exit 5293526
448
+    fi
427 449
     if [[ $ENABLE_BACKUP_VERIFICATION == "yes" ]]; then
428 450
         echo "$BACKUP_DUMMY_PASSWORD" | duplicity verify --tempdir $BACKUP_TEMP_DIRECTORY --ssh-askpass --encrypt-key ${ADMIN_BACKUP_KEY_ID} --full-if-older-than 4W --exclude-other-filesystems ${1} $SERVER_DIRECTORY/backup/${2}
429 451
         if [ ! "$?" = "0" ]; then