Borg: Incorrect borg prune --stats output with --dry-run

Created on 15 Feb 2019  路  10Comments  路  Source: borgbackup/borg

With borg 1.1.7 on ubuntu 18.10:

borg prune <borg_dir> --dry-run --list --stats --keep-last 1 
...
                       Original size      Compressed size    Deduplicated size
Deleted data:                    0 B                  0 B                  0 B
All archives:              981.25 GB            793.40 GB            112.32 GB

                       Unique chunks         Total chunks
Chunk index:                  250054              2164226
borg prune <borg_dir> --list --stats --keep-last 1 
...
                       Original size      Compressed size    Deduplicated size
Deleted data:             -820.45 GB           -669.72 GB             -9.60 GB
All archives:              160.80 GB            123.69 GB            102.72 GB

                       Unique chunks         Total chunks
Chunk index:                  237044               371408

Pruning worked as I wanted it to, but the dry run stats do not give an accurate preview.

easy good first issue

All 10 comments

Likely, that is simply not implemented (just guessing, needs to be checked in the src).

I had the look at the src:

  • the intended purpose of borg prune --dry-run is to see what archives would be deleted (pruned) and what would be kept. this is mostly to avoid calling it with wrong arguments and losing backups (if called w/o -dry-run).
  • as a dry-run does not even call archive.delete() (and stats are updated there, for real runs), there is no way it can show accurate stats with --dry-run.
  • due to deduplication, it is non-trivial and not fast to give accurate stats. it would have to emulate all the refcounting without actually deleting anything.

Proposed fix:
emit an error message saying --dry-run and --stats can't be used together.

If this is still available, could i work on this issue.

sure, go for it, make a PR.

@4rund3v did you have a look?

@ThomasWaldmann

some tests do use --dry-run and --stats together

i think we could add a simple check in archiver.run would that be appropriate ?

@user062 yes. there already some such checks.

Rather than exiting when someone uses --dry-run and --stats together, could we instead give then a warning and continue to run the dry-run while ignoring the stats?

My reasoning is that this current change breaks my wrapper script's current succinct of handling real/dry purges ( https://notabug.org/demure/scripts/src/master/borg_wrap.sh#L138-L150 ).

If the decision is to leave this as is, I'll just make my wrapper list two full commands I suppose, but this feel like an unintended roadblock so I figured I'd point it out.

ps. sorry I didn't notice this sooner, but I haven't pruned in a long time.

OK, guess we can do that, reopening...

Fixed in 1.1-maint, todo for master.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

htho picture htho  路  5Comments

russelldavis picture russelldavis  路  3Comments

anarcat picture anarcat  路  4Comments

auanasgheps picture auanasgheps  路  5Comments

qknight picture qknight  路  6Comments