KenKundert / borg-space

Accessory for Emborg used to report and track the size of your Borg repositories
GNU General Public License v3.0
4 stars 1 forks source link

Can't run borg-space in the 'run_after_backup' as it causes emborg to fail, meaning size isn't written #8

Closed adhawkins closed 1 year ago

adhawkins commented 1 year ago

If borg-space is run from the 'run_after_backup' setting, it looks like emborg hasn't yet written the size:

Running Borg create command ...
------------------------------------------------------------------------------
Repository: [ssh://i634u8fm@i634u8fm.repo.borgbase.com/./repo](mailto:ssh://i634u8fm@i634u8fm.repo.borgbase.com/./repo)
Archive name: 2023-06-05-21-05-58
Archive fingerprint: f3130428a6764cc0bab96ac5f51c77a997e41e950c874baefc1ee24fe085badd
Time (start): Mon, 2023-06-05 21:06:00
Time (end):   Mon, 2023-06-05 21:06:18
Duration: 17.98 seconds
Number of files: 15248
Utilization of max. archive size: 0%
------------------------------------------------------------------------------
                       Original size      Compressed size    Deduplicated size
This archive:               96.58 GB             94.74 GB              1.70 kB
All archives:                2.32 TB              2.27 TB             90.54 GB

                       Unique chunks         Total chunks
Chunk index:                   47437              1197568
------------------------------------------------------------------------------
emborg error: run_after_backup, 0, borg-space:
    Traceback (most recent call last):
      File "/usr/bin/borg-space", line 8, in <module>
        sys.exit(main())
                 ^^^^^^
      File "/usr/lib/python3.11/site-packages/borg_space/main.py", line 329, in main
        repos = collect_repos(requests, cmdline['--record'])
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/site-packages/borg_space/main.py", line 84, in collect_repos
        data[now] = repo['size'].fixed()
                    ~~~~^^^^^^^^
    KeyError: 'size'
emborg returns 2

I have both 'prune_after_create' and 'check_after_create' set to False in the config. This is what I have for 'run_after_backup':

#run_after_backup = [
#       'borg-space -r {config_name} --style compact',
#       'borg-space -g -S /var/www/localhost/htdocs/{config_name}.svg {config_name}'
#]
KenKundert commented 1 year ago

This issue should be fixed in the new version on github. Please give it a try and let me know how it works for you.