How to create offline LXC template or filetree image as template

(similar to --ostemplate option for “vzctl create”)

I want to deploy an LXC container with “dir” backend. Then update, preinstall and preconfigure some packages. After this, I want to copy this apart (or in a tarball package), and reuse this copy to create many other containers with neither having to download files nor performing large software install operations.

I could backup a container filetree, and after make copies of that backup, but how can I move UIDs and GIDs in that filetree?

Supposing I have an Ext4 filesystem with a backup tree owned by UIDs range 100000-165535 , and after making a copy/restoration I need to move it to UIDs range 200000-265535.
How can I apply +100000 to every subdirectory and file in that tree?

go get -v -x github.com/lxc/lxd/fuidshift
This will build a standalone tool using the same shifting logic we have in LXD.
That tool can then be used to recursively shift filesystem trees.