1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-21 23:33:07 +00:00

Merge pull request #4544 from ThomasWaldmann/improve-compact

small borg compact improvements, fixes #4522
This commit is contained in:
TW 2019-05-07 14:42:48 +02:00 committed by GitHub
commit fe2e9d77e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 5 deletions

View file

@ -7,9 +7,7 @@ Examples
# compact segments and free repo disk space
$ borg compact /path/to/repo
# same as above plus clean up 17byte commit-only segments,
# use this one time after upgrading borg (server) to 1.2+
# to clean up the tiny segments files created by borg 1.1:
# same as above plus clean up 17byte commit-only segments
$ borg compact --cleanup-commits /path/to/repo

View file

@ -2777,12 +2777,20 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
This command frees repository space by compacting segments.
Use this regularly to avoid running out of space - you do not need to use this
after each borg command though.
after each borg command though. It is especially useful after deleting archives,
because only compaction will really free repository space.
borg compact does not need a key, so it is possible to invoke it from the
client or also from the server.
Depending on the amount of segments that need compaction, it may take a while.
Depending on the amount of segments that need compaction, it may take a while,
so consider using the ``--progress`` option.
When using ``--verbose``, borg will output an estimate of the freed space.
After upgrading borg (server) to 1.2+, you can use ``borg compact --cleanup-commits``
to clean up the numerous 17byte commit-only segments that borg 1.1 did not clean up
due to a bug. It is enough to do that once per repository.
See :ref:`separate_compaction` in Additional Notes for more details.
""")

View file

@ -695,6 +695,7 @@ def compact_segments(self):
if not self.compact:
logger.debug('nothing to do: compact empty')
return
freed_space = 0
index_transaction_id = self.get_index_transaction_id()
segments = self.segments
unused = [] # list of segments, that are not used anymore
@ -734,6 +735,7 @@ def complete_xfer(intermediate=True):
segment, freeable_ratio * 100.0, freeable_space)
pi.show()
continue
freed_space += freeable_space # this is what we THINK we can free
segments.setdefault(segment, 0)
logger.debug('compacting segment %d with usage count %d (freeable: %2.2f%% [%d bytes])',
segment, segments[segment], freeable_ratio * 100.0, freeable_space)
@ -814,6 +816,7 @@ def complete_xfer(intermediate=True):
pi.show()
pi.finish()
complete_xfer(intermediate=False)
logger.info('compaction freed about %s repository space.', format_file_size(freed_space))
logger.debug('compaction completed.')
def replay_segments(self, index_transaction_id, segments_transaction_id):