query quota set / use from repository
Is there any way to query the quota introduced in https://github.com/borgbackup/borg/pull/2565? So that I, as a borg client/borg user, check how much size my remote repo already uses and how much space I still have left, so that I can potentially tweak my prune settings, manually delete large archives, etc.
:moneybag: there is a bounty for this
should tell:
- storage quota use (as we track it in hints)
- storage quota set (from repo config or overridden via borg serve option)
implementation:
- for local repos should be rather easy (but of limited application as quotas might be most frequently used by backup space providers)
- for remote (ssh:) repos needs a new rpc call
From repository.py:
def log_storage_quota(self):
if self.storage_quota:
logger.info('Storage quota: %s out of %s used.',
format_file_size(self.storage_quota_use), format_file_size(self.storage_quota))
@rugk looks like quota available and actual use is already logged - if you are logging at INFO level.
This code is called by commit() and prepare_txn().
So, just logging at INFO level and looking in your logs seems to solve this, without introducing a new RPC api.
Okay, thanks. However, at least borg info or so should show it, should not it?
Looking deep into some (info) logs cannot be a solution…
As it is currently implemented, the used-quota stored in the hints file is only loaded when a transaction is started.
And why is looking into a log not a solution? :)
Asked otherwise. Why should not it be displayed in borg info? It is a very useful information for the user when backing up., especially as it is critical if the space runs low. Just a simple "Usage: XX bytes out of XY bytes"?
…or, for that reason, after a backup was created with borg create.
I'm thinking about implementing this. As I understand @rugk wants to add quota info to the output of info and create.
Where in the output should I put it? At the top so it looks like this?
Used quota: 123MB out of 5GB
Archive name: 1
Archive fingerprint: f2718537357293f6458b9c622b15c08577c036b50e650c129c12ffdbc2206fbe
...
Archive name: 2
...
And in borg create should I add it to the --stats option? create doesn't give any output by default.
@ThomasWaldmann Did you read my comment?
The obvious place to output the quota information is borg info I'ld say.
Not a big fan from putting more and more into borg create output.
Can I get this assigned?
@francoo98 thanks for working on this. claim the bounty!
You're welcome, I'm happy to help 😁