Skip to content

Instantly share code, notes, and snippets.

@enkore
Last active August 23, 2023 18:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enkore/92216e919bc0ad2602d4a429bed597fb to your computer and use it in GitHub Desktop.
Save enkore/92216e919bc0ad2602d4a429bed597fb to your computer and use it in GitHub Desktop.
Show freeable space in a borg repository.
"""
{[0]} path/to/hints.N
Show freeable space in a borg repository.
That is, amount of bytes accounted to deleted objects that have not been
compacted away yet.
"""
import sys
import msgpack
if len(sys.argv) != 2:
print(__doc__.format(sys.argv).strip())
sys.exit(0)
print("Pointed at hints file:", sys.argv[1])
with open(sys.argv[1], 'rb') as file:
hints = msgpack.unpack(file)
assert hints[b'version'] == 2, "Need v2 hints file"
print("Freeable space:", sum(hints[b'compact'].values()), "bytes")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment