Error: Failed importing MACHINE_NAME_HERE: Failed creating instance record: Unknown configuration key: volatile.cloud-init.instance-id

So I have just taken backups from a 20.04 Focal machine and reinstalled focal and tried to import the exported images and I am getting this error.

I have Googled it and I have seen that Stephane wrote that it is to do with a versioning problem. But this leaves me confused as both LXD instances where installed via Snap which means they should be at the latest version and I only exported the machine an hour before I tried to import it on the new machine.

Can I just remove the volatile.cloud-init.instance-id key from the machine_name/index.yaml file, or will that break it?

How can I get rid of this error?

Thanks.

UPDATE:
I extracted the MACHINE_NAME_HERE.tar.gz that got made from the lxc export command and ran grep -r "volatile.cloud-init.instance-id" /MACHINE_NAME_HERE and found the key in a couple of places and deleted it.

I then repackaged it up as tar -vzcf MACHINE_NAME_HERE.tar.gz MACHINE_NAME_HERE and ran lxc import MACHINE_NAME_HERE and it imported no problem. Then all I had to do was run lxc start MACHINE_NAME_HERE and it was back to how it was.

It sounds like you were trying to import an export from a newer version of LXD into an older version of LXD.

They can both be installed from snap but following different version channels.

See Managing the LXD snap