From: Christoph Egger Date: Mon, 5 Jan 2015 17:58:32 +0000 (+0100) Subject: [backup-zfs] regularly flush remotefile X-Git-Url: https://git.siccegge.de//index.cgi?p=tools.git;a=commitdiff_plain;h=03d60516ab3fea2690ccee9a8cdc073412ee9432 [backup-zfs] regularly flush remotefile --- diff --git a/backup-zfs b/backup-zfs index 476d903..9eef4c2 100755 --- a/backup-zfs +++ b/backup-zfs @@ -107,6 +107,7 @@ def sftp_send(dataset, reference=None): 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() @@ -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) + + if done - lastflush > 128 * 1024**2: + remotefile.flush() + lastflush = done + digest.update(junk) junk = gpg.stdout.read(BUFFER)