Skip to content

Easy way to retrieve hints data from encrypted repository without key #5050

@felinira

Description

@felinira

Is there an easy way to retrieve hints (and other) data from an encrypted repository without having the key? I would like to parse the currently used quota on my backup server to send quota warnings to users without needing to enter a passphrase. I also don't want to spend time scrubbing the disk to get an estimated quota that is even slightly wrong.

My quick and dirty way:

def get_borg_repo_hints(repo_path):
    import os
    from borg.repository import Repository
    from borg.helpers import msgpack

    repo = Repository(repo_path)
    transaction_id = repo.get_index_transaction_id()
    hints_path = os.path.join(repo_path, 'hints.%d' % transaction_id)
    with open(hints_path, 'rb') as fd:
        hints = msgpack.unpack(fd)
    return hints

This is of course not very safe, doesn't use locking and doesn't verify the hints file integrity. I could expand this of course, by following the implementation from Repository.prepare_txn() but I don't really want to and don't think it is a good idea to re-implement borg repository handling outside of borg itself.

Is there a better way without digging even deeper and reimplementing even more? (I would prefer to just run borg info --json but this requires a passphrase which I do not have and do not want.)

If not: Would it be feasible to add an option (like --only-unencrypted) to borg info or borg debug that would make it possible to retrieve all information that is not encrypted?

(I know I am working against the borg attack model here. But some data will never be encrypted because it is impossible to combine server enforced repository quotas without the server being able to read/write the used quota value. If it is not encrypted it should not be hard to make use of it.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions