]> git.siccegge.de Git - tools.git/commitdiff
[backup-zfs] regularly flush remotefile
authorChristoph Egger <christoph@christoph-egger.org>
Mon, 5 Jan 2015 17:58:32 +0000 (18:58 +0100)
committerChristoph Egger <christoph@christoph-egger.org>
Mon, 5 Jan 2015 17:59:51 +0000 (18:59 +0100)
backup-zfs

index 476d903a34994459067f7271ee4786ec68139d03..9eef4c24c6de3f68eabc424b60e1fbe60e961f1c 100755 (executable)
@@ -107,6 +107,7 @@ def sftp_send(dataset, reference=None):
         print_colored("Error:\n\n" + gpg.stderr, 'red')
         return
 
         print_colored("Error:\n\n" + gpg.stderr, 'red')
         return
 
+    lastflush = 0
     with open('/tmp/SHA256SUM', 'a') as digestfile:
         with sftp.open(filename, 'xw', BUFFER) as remotefile:
             digest = hashlib.sha256()
     with open('/tmp/SHA256SUM', 'a') as digestfile:
         with sftp.open(filename, 'xw', BUFFER) as remotefile:
             digest = hashlib.sha256()
@@ -125,6 +126,11 @@ def sftp_send(dataset, reference=None):
                     sys.stdout.write("     \r%s %.3f GB      (%.3f MB/s)" % (term['green'], (1.0 * done) / (1024 ** 3), (done / (1024 ** 2 *(time.time() - startt)))))
                     sys.stdout.flush()
                 remotefile.write(junk)
                     sys.stdout.write("     \r%s %.3f GB      (%.3f MB/s)" % (term['green'], (1.0 * done) / (1024 ** 3), (done / (1024 ** 2 *(time.time() - startt)))))
                     sys.stdout.flush()
                 remotefile.write(junk)
+
+                if done - lastflush > 128 * 1024**2:
+                    remotefile.flush()
+                    lastflush = done
+
                 digest.update(junk)
                 junk = gpg.stdout.read(BUFFER)
 
                 digest.update(junk)
                 junk = gpg.stdout.read(BUFFER)