aruhier / virt-backup

Backup your kvm guests managed by libvirt
Other
107 stars 23 forks source link

clean command does not work when using zstd as compression and there are pending/aborted backups #51

Closed mikewzr closed 9 months ago

mikewzr commented 9 months ago

I recently switch to zstd as compression, which work fine until a backup did not finish. Now when starting the clean command, it fails with following error:

Traceback (most recent call last):
  File "/usr/local/bin/virt-backup", line 8, in <module>
    sys.exit(cli_run())
  File "/usr/local/lib/python3.9/dist-packages/virt_backup/__main__.py", line 27, in cli_run
    return parse_args_and_run(build_parser())
  File "/usr/local/lib/python3.9/dist-packages/virt_backup/__main__.py", line 151, in parse_args_and_run
    args.func(parsed_args=args)
  File "/usr/local/lib/python3.9/dist-packages/virt_backup/__main__.py", line 277, in clean_backups
    g.name or "Undefined", len(g.clean(**clean_params))
  File "/usr/local/lib/python3.9/dist-packages/virt_backup/groups/complete.py", line 238, in clean
    b.delete()
  File "/usr/local/lib/python3.9/dist-packages/virt_backup/backups/complete.py", line 177, in delete
    packager = self._get_write_packager()
  File "/usr/local/lib/python3.9/dist-packages/virt_backup/backups/complete.py", line 171, in _get_write_packager
    return super()._get_write_packager(self.name)
  File "/usr/local/lib/python3.9/dist-packages/virt_backup/backups/__init__.py", line 55, in _get_write_packager
    return getattr(WriteBackupPackagers, self.packager).value(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'compression'

I assume that it has something to do with the JSON files (or the .pending files) as these have a the compression keyword in them, which normally isn't used with zstd. This is a snippet from one of the JSON file, which did not finish:

    "packager": {
        "type": "zstd",
        "opts": {
            "compression": "zstd",
            "compression_lvl": 15
        }
    },

The finished ones look like this:

    "packager": {
        "type": "zstd",
        "opts": {
            "compression_lvl": 15
        }
    },
aruhier commented 9 months ago

Thanks for the bug report! I tested, it is surprising as nothing outside of the tar packager sets the "compression" option. I tested on a hypervisor and I couldn't replicate this behavior.

However, I made the constructor of each packager more resilient to that, so even if a json contains some unexpected fields, they'll be ignored instead of failing.

mikewzr commented 9 months ago

Ya, don't know either. Especially, as the finished ones also don't have the "compression" option.

Anyway, thanks for the rapid resolution!