-
Activate a session to the source tenant
set-session -
Save the data to file
c8y devices list --pageSize 10 > tenant1.json -
Change to the target tenant (where the data will be created in)
-
Create the managed objects (removing protected properties using a default view)
cat tenant1.json \ | c8y util show --view ignoreinbuilt_id \ | c8y util show --select '**,!owner' \ | c8y inventory create --template "input.value" --dry
If you are doing a lot of data, and what to make sure you don't create duplicates when you rerun the one-liner, then you can use the caching mechanism (available on all commands, see https://goc8ycli.netlify.app/docs/concepts/caching/)
This is the same example but using the global caching options:
cat tenant1.json \ | c8y util show --view ignoreinbuilt_id \ | c8y util show --select '**,!owner' \ | c8y inventory create --template "input.value" --cache --cacheTTL 1d --dry
-
Change to the source tenant
set-session -
List the managed object from the current tenant, and use the results to create the managed objects in a session tenant (using
--session <session>)c8y devices list --pageSize 10 \ | c8y util show --view ignoreinbuilt_id \ | c8y util show --select '**,!owner' \ | c8y inventory create --template "input.value" --cache --cacheTTL 1d --dry --session secondtenant.json