Skip to content

Commit

Permalink
backup: throttle backup extracting if there is not enough disk space
Browse files Browse the repository at this point in the history
Instead of failing the restore process, pause data extracting, until
already extracted data gets processed.
This commit implements this for local tar extraction. Extracting data
received from a VM is handled in qfile-(dom0-)unpacker, which also has
similar feature, turned on in 6338b93.

Fixes QubesOS/qubes-issues#4791
  • Loading branch information
marmarek committed Jan 5, 2021
1 parent 10d4381 commit 9360865
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions qubesadmin/backup/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,8 +1005,18 @@ def _start_retrieval_process(self, filelist, limit_count, limit_bytes):
else:
backup_stdin = open(self.backup_location, 'rb')

block_size = os.statvfs(self.tmpdir).f_frsize

# slow down the restore if there is too little space in the temp dir
checkpoint_command = \
'while [ $(stat -f --format=%a "{}") -lt {} ]; ' \
'do sleep 1; done' \
.format(self.tmpdir, 500 * 1024 * 1024 // block_size)

tar1_command = ['tar',
'-ixv',
'--checkpoint=10000',
'--checkpoint-action=exec=' + checkpoint_command,
'--occurrence=1',
'-C', self.tmpdir] + filelist

Expand Down

0 comments on commit 9360865

Please sign in to comment.