Bläddra i källkod

verify backups

Bob Mottram 9 år sedan
förälder
incheckning
7de611fcc8
2 ändrade filer med 28 tillägg och 8 borttagningar
  1. 10
    0
      src/freedombone-backup-local
  2. 18
    8
      src/freedombone-backup-remote

+ 10
- 0
src/freedombone-backup-local Visa fil

@@ -171,6 +171,16 @@ function backup_directory_to_usb {
171 171
         fi
172 172
         obnam force-lock -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
173 173
         obnam backup -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
174
+        obnam verify -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
175
+        if [ ! "$?" = "0" ]; then
176
+            umount $USB_MOUNT
177
+            rm -rf $USB_MOUNT
178
+            if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
179
+                shred -zu ${1}/*
180
+                rm -rf ${1}
181
+            fi
182
+            exit 71
183
+        fi
174 184
         obnam forget --keep=30d -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID
175 185
         if [ ! "$?" = "0" ]; then
176 186
             umount $USB_MOUNT

+ 18
- 8
src/freedombone-backup-remote Visa fil

@@ -76,16 +76,26 @@ function backup_directory_to_friend {
76 76
     if [ ! -d $SERVER_DIRECTORY/backup/${2} ]; then
77 77
         mkdir -p $SERVER_DIRECTORY/backup/${2}
78 78
     fi
79
-    obnam force-lock -r $SERVER_DIRECTORY/backup/${2} --encrypt-with $ADMIN_BACKUP_KEY_ID ${1}
80
-    obnam backup -r $SERVER_DIRECTORY/backup/${2} --encrypt-with $ADMIN_BACKUP_KEY_ID ${1}
81
-    obnam forget --keep=30d -r $SERVER_DIRECTORY/backup/${2} --encrypt-with $ADMIN_BACKUP_KEY_ID
79
+    obnam force-lock -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID} ${1}
80
+    obnam backup -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID} ${1}
81
+    obnam verify -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID} ${1}
82 82
     if [ ! "$?" = "0" ]; then
83 83
         if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
84 84
             shred -zu /root/temp${2}/*
85 85
             rm -rf /root/temp${2}
86 86
         fi
87 87
         # Send a warning email
88
-        echo "Unable to backup ${2}" | mail -s "${PROJECT_NAME} backup to friends" $ADMIN_EMAIL_ADDRESS
88
+        echo "Unable to verify ${2}" | mail -s "${PROJECT_NAME} backup to friends" ${ADMIN_EMAIL_ADDRESS}
89
+        exit 953
90
+    fi
91
+    obnam forget --keep=30d -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID}
92
+    if [ ! "$?" = "0" ]; then
93
+        if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
94
+            shred -zu /root/temp${2}/*
95
+            rm -rf /root/temp${2}
96
+        fi
97
+        # Send a warning email
98
+        echo "Unable to backup ${2}" | mail -s "${PROJECT_NAME} backup to friends" ${ADMIN_EMAIL_ADDRESS}
89 99
         exit 853
90 100
     fi
91 101
     if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
@@ -127,9 +137,9 @@ function backup_configuration {
127 137
     fi
128 138
     cp -f $CONFIG_FILE /root/tempbackupconfig
129 139
     cp -f $COMPLETION_FILE /root/tempbackupconfig
130
-	if [ -f $BACKUP_EXTRA_DIRECTORIES ]; then
131
-		cp -f $BACKUP_EXTRA_DIRECTORIES /root/tempbackupconfig
132
-	fi
140
+    if [ -f $BACKUP_EXTRA_DIRECTORIES ]; then
141
+        cp -f $BACKUP_EXTRA_DIRECTORIES /root/tempbackupconfig
142
+    fi
133 143
     backup_directory_to_friend /root/tempbackupconfig config
134 144
 }
135 145
 
@@ -486,7 +496,7 @@ function backup_extra_directories {
486 496
         if [ -d "$backup_dir" ]; then
487 497
             destination_dir=$(echo "$backup_line" | awk -F ',' '{print $2}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
488 498
             if [[ $(valid_backup_destination "$destination_dir") == "yes" ]]; then
489
-				backup_directory_to_friend "$backup_dir" "$destination_dir"
499
+                backup_directory_to_friend "$backup_dir" "$destination_dir"
490 500
             else
491 501
                 echo $"WARNING: The backup directory $destination_dir is already used."
492 502
                 echo $"Choose a different destination name for backing up $backup_dir"