Import lxd containers with different dir structure

I have trouble importing lxd exported containers with different dir structure.
I.e. exported container dir storage /home/seven/some/lxd
And to be imported to /home/dude/lxd
It just wont allow, is there a way around?

You can try:

  • create a new container
  • stop it
  • remove all the files from its file tree
  • unpack the exported archive,
  • move or copy the archived file tree, to the new container’s file tree
  • reapply any profile or other configuration that the old container had (it helps to have all or most of the configuration in profiles)
  • start the new container
    Now the new container should have the exported container’s contents, and it should work as if it were the exported container.

I have tried replacing the file tree with zfs containers and it works.
Container import is very picky about requiring the same configuration that the export system had. It’s not portable. I don’t use it for this reason.

What you say is right, but i wonder there should be easier backup options, or at least the import to ignore dir structure maybe, no?

I think if you created a dir storage pool of the same name as the original and import it, then create a new storage pool for the new directory and then move the containers from the old pool to the new pool should do it.