borgbackup / borg

Deduplicating archiver with compression and authenticated encryption.
https://www.borgbackup.org/
Other
11.23k stars 743 forks source link

Show repository size in bytes or fixed unit #5513

Open ygoe opened 4 years ago

ygoe commented 4 years ago

Have you checked borgbackup docs, FAQ, and open Github issues?

Yes

Is this a BUG / ISSUE report or a QUESTION?

Question

System information. For client/server mode post info for both machines.

Your borg version (borg -V).

1.1.11, ready to upgrade if necessary

Operating system (distribution) and version.

Ubuntu 18.04, 20.04

Hardware / network configuration, and filesystems used.

SSH remote

How much data is handled by borg?

Gigabytes

Full borg commandline that lead to the problem (leave away excludes and passwords)

borg info $REPOSITORY

Describe the problem you're observing.

The output looks like this:

(…)
                       Original size      Compressed size    Deduplicated size
All archives:                2.03 TB            572.85 GB            258.76 GB
(…)

I want to parse the last number and use it for my monitoring. Multiple borg backups go to the same remote SSH account so I cannot simply fetch the disk usage from there, it's the sum of all repositories. To know which of the repositories is large, I need separate numbers.

My borg wrapper is a Bash script. I could probably parse those human-friendly formatted numbers but I'd like to know if there's a commandline switch to spare me and borg the additional work. Haven't tried the JSON format but I'd like to skip the dependency on jq if possible, and this is a simple case for parsing with grep and awk.

The documentation doesn't list such a parameter. I wanted to inspect the source code but could not find the relevant part for the info command.

ThomasWaldmann commented 4 years ago

IIRC:

ThomasWaldmann commented 4 years ago

if you use multiple repos, they have multiple repo directories, so you actually can just use du on them.

ygoe commented 3 years ago

Okay, JSON puts this on a separate line so it can be parsed, too. Can I rely on the JSON format, will it stay like this and not change to a single-line (non-formatted) output?

du is not supported on Hetzner Storage Boxes via SFTP, so I can't use that. SSH shell access is not available.

ThomasWaldmann commented 3 years ago

No, you can't really rely on that, sorry.

While there are no current plans to change that, I guess we can only guarantee that the json will be valid json, not that it will be formatted in a specific way forever.

ygoe commented 3 years ago

Well, could I then suggest adding a general commandline option like --bytes to always show any size in bytes and not scale them down to smaller numbers?

ThomasWaldmann commented 3 years ago

well, other commands already have --format so somebody could check whether it can be implemented similar to what we have.