---
title: Copying a tenant to a different environment
slug: hyper-portal/copying-a-tenant-to-a-different-environment
docTags: 
createdAt: 2021-07-08T14:00:04.000Z
---

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.



![](https://api.archbee.com/api/optimize/5goaGPkGyPYxtK7K75CEC/huAZcxkZ0gwydByHpHiAs_image.png "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.

![](https://api.archbee.com/api/optimize/5goaGPkGyPYxtK7K75CEC/ImJvWEuY012X5nyMfkuJD_image.png "Unneeded variables that will not let you import unless you are root user")



![](https://api.archbee.com/api/optimize/5goaGPkGyPYxtK7K75CEC/nWrXD77kUqu1cB1lpJoL9_image.png "form template tables have a lot of formatting errors")

![](https://api.archbee.com/api/optimize/5goaGPkGyPYxtK7K75CEC/wlP7HeMUv6K7ElmZLmVXz_image.png "database import")

## -copy S3 bucket

Simpy find needed source bucket on&#x20;


-re-index elasticsearch
-----------------------


-adjust dynamodb record
-----------------------


-manually save email templates
------------------------------


-create needed delayed nodes
----------------------------


-manually recreate Forms
------------------------





