Search code examples
kiwi-tcms

KiwiTCMS restoring a json backup file fails with "Problem installing fixture '-' error"


I have been using KiwiTCMS docker image installation. There were a crash lately and machine broke down. I do have Kiwi docker image 6.11 and backup for same image available.

Backup is made with command:

  docker exec -it kiwi_web /Kiwi/manage.py dumpdata --all --indent 2 > database.json

KiwiTCMS is run up with

docker-compose up -d

Now when trying to restore the backup with sequence (docker-compose.yml is pointing to correct kiwi-web image, and SQL is pointing to kiwi-db 5.5 mariadb image), I get an error

# docker-compose up -d
# docker exec -it kiwi_web /Kiwi/manage.py migrate
# cat database.json | docker exec -i kiwi_web /Kiwi/manage.py loaddata --format json -

Error:

Traceback (most recent call last):
  File "/venv/lib/python3.6/site-packages/django/db/models/options.py", line 565, in get_field
    return self.fields_map[field_name]
KeyError: 'execution'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/venv/lib/python3.6/site-packages/django/core/serializers/json.py", line 69, in Deserializer
    yield from PythonDeserializer(objects, **options)
  File "/venv/lib/python3.6/site-packages/django/core/serializers/python.py", line 118, in Deserializer
    field = Model._meta.get_field(field_name)
  File "/venv/lib/python3.6/site-packages/django/db/models/options.py", line 567, in get_field
    raise FieldDoesNotExist("%s has no field named '%s'" % (self.object_name, field_name))
django.core.exceptions.FieldDoesNotExist: LinkReference has no field named 'execution'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Kiwi/manage.py", line 12, in <module>
    execute_from_command_line(sys.argv)
  File "/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/venv/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/venv/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/venv/lib/python3.6/site-packages/django/core/management/commands/loaddata.py", line 72, in handle
    self.loaddata(fixture_labels)
  File "/venv/lib/python3.6/site-packages/django/core/management/commands/loaddata.py", line 114, in loaddata
    self.load_label(fixture_label)
  File "/venv/lib/python3.6/site-packages/django/core/management/commands/loaddata.py", line 172, in load_label
    for obj in objects:
  File "/venv/lib/python3.6/site-packages/django/core/serializers/json.py", line 73, in Deserializer
    raise DeserializationError() from exc
django.core.serializers.base.DeserializationError: Problem installing fixture '-': 

How could I proceed to save the backupped data somehow?

Thank you very much, -Mika


Solution

  • FieldDoesNotExist: LinkReference has no field named 'execution'

    well this tells you what your error is! You are trying to restore a DB dump from version 6.11 onto a later version and that will not work because there have been [possibly multiple] changes in the database schema meanwhile.

    docker-compose.yml is pointing to correct kiwi-web image

    This is obviously not the case because LinkReference.execution field appeared in version 7.0, see https://kiwitcms.readthedocs.io/en/latest/changelog.html#id108

    So to recap:

    • you are trying to restore a database dump from an older (or newer) version of Kiwi TCMS while the app server is running an incompatible version. This will not work.
    • Make sure your docker-compose.yml is using Kiwi TCMS v6.11 and not latest

    Your options:

    • Figure out what fields have changed (from which version is your json dump) and modify the JSON structure to match - time consuming and prone to errors
    • Get yourself exactly the same old version of Kiwi TCMS and then restore the data onto it.