encrypted_backups_to_the_cloud

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revisionBoth sides next revision
encrypted_backups_to_the_cloud [13.08.2017 16:57] – [the script] Pascal Suterencrypted_backups_to_the_cloud [15.08.2017 08:06] – [the script] Pascal Suter
Line 78: Line 78:
 #!/bin/bash  #!/bin/bash 
  
-# (c) 2017 Pascal Suter, Version 1.0+# (c) 2017 Pascal Suter, Version 0.10 Beta
 # this script creates an enecrypted offsite backup of a locally kept backup.  # this script creates an enecrypted offsite backup of a locally kept backup. 
 # ideally suited to work with rubi (http://www.0x1b.ch/misc/hacks/rubi) # ideally suited to work with rubi (http://www.0x1b.ch/misc/hacks/rubi)
Line 99: Line 99:
     echo "$1" | mail -s "offsiteBackup failed" "$RECIPIENTS"     echo "$1" | mail -s "offsiteBackup failed" "$RECIPIENTS"
     exit 1     exit 1
 +}
 +
 +function success {
 +    ( echo "the offsite backup was successfully updated to backup version $LATEST"
 +    echo "here are the last lines of the rsync process:"
 +    tail -n 3 /tmp/offsiteBackup.log ) | mail -s "offsiteBackup successfully updated" "$RECIPIENTS"
 +    umount $PLAINMOUNT 2>/dev/null
 +    exit 0
 } }
  
Line 134: Line 142:
  
 # rsync to offsite location # rsync to offsite location
-rsync -AaHvXx $RSYNCOPTS "$CRYPTED/" "$TARGET" +rsync -AaHvXx --delete $RSYNCOPTS "$CRYPTED/" "$TARGET" 2>&
-if [ $-gt 0 ]; then +res=$? 
-    fail "there was a problem with the offsite backup, check /tmp/offsiteBackup.log on the server"+if [ $res -gt 0 ]; then 
 +    if [ $res -eq 24 ]; then  
 +        #some files vanished during the backup, that's not a failure of the backup, so send the success message  
 +        success 
 +    else  
 +        fail "there was a problem with the offsite backup, check /tmp/offsiteBackup.log on the server" 
 +    fi
 else  else 
-    ( echo "the offsite backup was successfully updated to backup version $LATEST" +    success
-    echo "here are the last lines of the rsync process:" +
-    tail -n 3 /tmp/offsiteBackup.log ) | mail -s "offsiteBackup successfully updated" "$RECIPIENTS"+
 fi fi
 </code> </code>
 +=== Known Issues ===
 +For some reason gocryptfs seems to generate some files like '' gocryptfs.longname.*.name'' that are there when rsync scans the directory but vanish before rsync can sync them. this leads to rsync complaining about vanished files. when i mount the backup with gocryptfs (forward) and then compare the unencrypted backup with the original through rsync --dry-run i find the same number of files as missing files in my encrypted backup. they have very long filenames like this one: ''xxxx/xxxx/vlc-shares/public/images/fsthumbs/thumbs/MjovVFYvQWxhcm0gZnVyIENvYnJhIDExIC0gRGllIEF1dG9iYWhucG9saXplaSAtIFNlYXNvbiAxLTEyL0NvYnJhIDExIFN0YWZmZWwgMDEvQ29icmEgMTEgUzAxIEUwMDYgKERlciBBbHRlIHVuZCBkZXIgSnVuZ2UpLmF2aQ==.jpg''. the script accepts exit code 24 (vanished files) as successful ending of rsync for now until i have time to further investigate and either file a bug at gocryptfs or work around it somehow. 
 +
 ===== Restoring Files ===== ===== Restoring Files =====
 to restore files you could use ''sshfs'' for example to mount the remote directory via ssh on your local server... to restore files you could use ''sshfs'' for example to mount the remote directory via ssh on your local server...
  • encrypted_backups_to_the_cloud.txt
  • Last modified: 15.08.2017 08:44
  • by Pascal Suter