From 03d60516ab3fea2690ccee9a8cdc073412ee9432 Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Mon, 5 Jan 2015 18:58:32 +0100 Subject: [PATCH] [backup-zfs] regularly flush remotefile --- backup-zfs | 6 ++++++ 1 file changed, 6 insertions(+) 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) -- 2.39.5