View Issue Details

IDProjectCategoryView StatusLast Update
0001212bareos-corebconsolepublic2020-06-25 13:09
Reporterhostedpower Assigned Toarogge  
Status resolvedResolutionno change required 
PlatformLinuxOSDebianOS Version9
Product Version19.2.6 
Summary0001212: Can no longer prune volumes
DescriptionWe have a script to prune volumes but since 19.2.x it returns error:

for pool, vols in'list volumes')['volumes'].items():
    for v in vols:
        if v['volstatus'] == 'Full' or v['volstatus'] == 'Used':
            print("Pruning %s" % v['volumename'])
  'prune volume=%s yes' % v['volumename'])

bareos.exceptions.JsonRpcErrorReceivedException: failed: {u'jsonrpc': u'2.0', u'id': None, u'error': {u'message': u'failed', u'code': 1, u'data': {u'messages': {u'info': [u'The current Volume retention period is: 3 months 10 days \n']}, u'result': {}}}}

Did anythong change in bconsole or is this a bug?

TagsNo tags attached.




2020-04-17 15:20

manager   ~0003947

This seems to be broken in 19.2.
I'm trying to find out which change introduced the problem so I can fix it. Can you tell my what exactly was the version you were running before (where the script worked)?
Thank you!


2020-04-17 16:09

manager   ~0003948

The problem was in the python-bareos library now handling errors differently.
I have attached a newer version of the script that should work with 19.2. This version should handle the retention message correctly.
I removed the functionality with the volume truncation as it should not be required. You can add it back if you want to. You may need to handle the exception when there were no volumes to be truncated. (1,101 bytes)   
#!/usr/bin/env python
from __future__ import print_function

from bareos.bsock import Password, DirectorConsoleJson
from bareos.exceptions import JsonRpcErrorReceivedException

password = Password("YOUR DIRECTOR PASSWORD")
con = DirectorConsoleJson(address="localhost", port=9101, password=password)

for pool, vols in"list volumes")["volumes"].items():
    for v in vols:
        if v["volstatus"] == "Full" or v["volstatus"] == "Used":
            print("Pruning %s ... " % v["volumename"], end="")
      "prune volume=%s yes" % v["volumename"])
            except JsonRpcErrorReceivedException as e:
                    if (
                        "The current Volume retention period is:"
                        in e.jsondata["error"]["data"]["messages"]["info"][0]
                        print("retention period not over")
                        raise e
                except KeyError:
                    raise e (1,101 bytes)   


2020-04-17 16:38

reporter   ~0003949

ok this part works!! Thanks!! :)

I'm checking:

for s in'.storages')['storages']:
    if s['enabled']:
      print ('Truncating volumes on storage %s' % s['name'])'truncate volstatus=Purged storage=%s yes' % s['name'])

But that also gives exception, I don't know how to handle this in a smart way , any hints on how to properly interpret and handle exceptions here? :)


2020-04-22 21:43

reporter   ~0003956

looking into this, if we don't explicitely truncate like you said, will the volumes be cleared/emptied? I think it did not and that's why is was added in the first place or what am I missing here? :)


2020-04-23 12:48

manager   ~0003960

The usual mode of operation is that volumes are overwritten when they were pruned.


2020-04-23 12:51

reporter   ~0003961

that wouldn't be bad, but it seems they build up too much sometimes, keeping more volumes with data than needed...


2020-04-23 14:31

reporter   ~0003962

Just added it as a test and it cleared up quite some extra space. My code is however not clean:

for s in'.storages')['storages']:
    if s['enabled']:
        print ('Truncating volumes on storage %s' % s['name'])
  'truncate volstatus=Purged storage=%s yes' % s['name'])
        except JsonRpcErrorReceivedException as e:

(It always excepts it seems, yet it executes properly)


2020-06-25 13:09

manager   ~0004012

The newer python-bareos treats some situations as errors that the previous one did not. Thus the client is now responsible for checking what happened and responding accordingly.

Issue History

Date Modified Username Field Change
2020-03-16 15:11 hostedpower New Issue
2020-04-17 15:20 arogge Assigned To => arogge
2020-04-17 15:20 arogge Status new => feedback
2020-04-17 15:20 arogge Note Added: 0003947
2020-04-17 16:09 arogge File Added:
2020-04-17 16:09 arogge Note Added: 0003948
2020-04-17 16:38 hostedpower Note Added: 0003949
2020-04-17 16:38 hostedpower Status feedback => assigned
2020-04-22 21:43 hostedpower Note Added: 0003956
2020-04-23 12:48 arogge Note Added: 0003960
2020-04-23 12:51 hostedpower Note Added: 0003961
2020-04-23 14:31 hostedpower Note Added: 0003962
2020-06-25 13:09 arogge Status assigned => resolved
2020-06-25 13:09 arogge Resolution open => no change required
2020-06-25 13:09 arogge Note Added: 0004012