Last active
August 23, 2023 18:01
-
-
Save enkore/92216e919bc0ad2602d4a429bed597fb to your computer and use it in GitHub Desktop.
Show freeable space in a borg repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
{[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