Copying a tenant to a different environment
5 min
When you need to copy a prod tenant to staging or vice versa and you have a lot of items to recreate, it may be more efficient to do it in a semi-automatic way.
Needed actions:
-clone DB
The first thing to do is to export source tenant database. Then delete existing tables from the target tenant and import the dump to the target.

database export
SET FOREIGN_KEY_CHECKS=0; DROP TABLE `nataliia3`.`auth_passwordless_codes`,..., `nataliia3` SET FOREIGN_KEY_CHECKS=1; delete old tables on target
Edit source dump file. Remove global variables and Forms related data.

Unneeded variables that will not let you import unless you are root user

form template tables have a lot of formatting errors

database import
-copy S3 bucket
Simpy find needed source bucket on
-re-index elasticsearch
-adjust dynamodb record
-manually save email templates
-create needed delayed nodes
-manually recreate Forms