Export users with auth0-deploy-cli

Hi, I’m new to auth0 and quite lost.

I created two tenants, one for staging, that I’ve been using successfully for testing the past two months with a SPA app, and one for production, that I will need to deploy soon.

Now I need to migrate all users and config from staging tenant to production, using the auth0-deploy-cli CLI tool. So:

  • On my staging tenant I created one Machine-To-Machine app called “Deploy/Import/Export CLI”, authorized on “Auth0 Management API”, .
  • On my production tenant, I created another Machine-To-Machine app also called “Deploy/Import/Export CLI”, also authorized on “Auth0 Management API”.

I use the auth0-deploy-cli and I run the command:
a0deploy export -c=config_export.json --output_folder=exports --env=false, with my config_export.json including the AUTH0_DOMAIN, AUTH0_CLIENT_ID, AUTH0_CLIENT_SECRET of my “Deploy/Import/Export CLI” app.

It successfully export most of the need data in the export folder, but I can’t see any users. Why? How can I also export/import users through the auth0-deploy-cli CLI tool?

Hi @bolino

The deploy-cli tool is for tenant configuration, and users are not considered part of the configuration; they are not moved.

Why do you need to move the users from staging to production? Usually it is a different set of users (only production has real users).

If you really want to do this, you can use the management API, in the jobs section, there are export and import jobs. They only work with DB users, not social users, and you cannot export password hashes. The import job is limited to 500K so if you have a lot of users you will have to break the export file up into several.

John

Hi John, thanks a lot for the prompt answer.

I need to move users from staging to production because users were created on a staging app during a two months internal testing phase. Sounds like a common use case to me. We might also have to want to access the staging with the same user accounts that have been created on production later on by copying them back, which is another important use case for us.

Anyway, we need to backup/restore all the settings and data, including the users (DB users are ok, I understand social users can"t be moved), from one tenant to another. Should we go for the management API or the auth0-deploy-cli? Is the management API also able to backup/restore all the settings from one tenant to another?

We had a look several days ago at the auth0 managementAPI but couldn’t find any example of request to export everything. Any example of that in the doc by any chance?

Hi @bolino

You will need both the management API and deploy-cli: the management API for the users, and deploy-cli for the config.

The export users job docs are here: Auth0 Management API v2
The import users docs are very close to that.

It is not a common use case due to PII: production users are usually considered PII and are not leaked to lower environments.

John

1 Like