# Source: https://docs.upsun.com/projects/region-migration.md

# Change a project's region

To host your project data, Upsun offers several [regions](https://docs.upsun.com../development/regions.md).
You specify a region when you create a project.

You can also change the project's region after it's created.

## Why migrate between regions

- Different data centers are located in different geographic areas.
  You may want your site close to your users for improved performance.
- You may want to move to a region with a lower [environmental impact](https://docs.upsun.com../development/regions.md#environmental-impact).

## 1. Plan the migration

Before starting the migration process, you need to plan for it:

- Plan a time frame in which to handle the migration.
  Your code shouldn't change during this time to ensure all changes are copied to the new project.
  Prepare for a brief site outage when you migrate, just as with a relaunch of a site.
- Set your DNS Time-to-Live as low as possible.
  This ensures the switch to the new site propagates as quickly as possible.

## 2. Create a new project

In the target region, [create a new project from scratch](
https://console.upsun.com/org/create-project/info?_utm_campaign=cta_deploy_marketplace_template&utm_source=public_documentation&_utm_medium=organic
).

If you plan to test for long, start with the least amount of resources on the project and then upsize it before switching the DNS.

## 3. Add code and environments

Select your newly created blank project.

 - Push the code for your production branch:

```bash {}
upsun push --target <PRODUCTION_BRANCH_NAME>
```

 - (Optional) Checkout other branches and then push their code:

```bash {}
upsun push --activate --target <BRANCH_NAME> --parent <PRODUCTION_BRANCH_NAME>
```

For a [source integration](https://docs.upsun.com/integrations/source.md) with GitHub, BitBucket, or GitLab,
add the integration to your new project.
Your new project then mirrors the configured repository automatically.

## 4. Copy files

If you have files in a mount, first download them:

```bash
upsun mount:download
```

Then upload them to your new project:

```bash
upsun mount:upload
```

See more options on [how to export files](https://docs.upsun.com/learn/tutorials/exporting.md)
and [how to import files](https://docs.upsun.com/learn/tutorials/migrating/from-fixed.md#6-import-data).

## 5. Copy data from services

For services with generated data such as Solr and Redis, you don't need to copy data directly.
Just rebuild the data in the new project.

To download data from persistent services such as databases,
see how to export and then import data for each service:

- [InfluxDB](https://docs.upsun.com../add-services/influxdb.md#export-data)
- [MongoDB](https://docs.upsun.com../add-services/mongodb.md#exporting-data)
- [MariaDB/MySQL](https://docs.upsun.com../add-services/mysql.md#exporting-data)
- [PostgreSQL](https://docs.upsun.com../add-services/postgresql.md#exporting-data)

## 6. Migrate variables and project settings

Make sure anything else connected to your old project is moved to your new project:

- If you have project or environment variables defined on your old project, add them to your new project.
  Get a list of all variables set outside of code by running `upsun variables`.
- Add any users to your new project that you want to continue to have access.
- Add any existing [integrations](https://docs.upsun.com../integrations.md).

## 7. Test the site

Verify that the new site is working as desired before continuing.
You can leave the two projects running for as long as you need.
After you have finished all your testing, sync all your data (code, files, database) for the last time.

## 8. Switch to the new site

Now that you know the new project works, switch public traffic to that site:

1. Make sure your new project has the [necessary resources](https://docs.upsun.com/manage-resources/adjust-resources.md).
2. If possible, put your site into read-only mode or maintenance mode.
3. Add your domain names to your new project and remove them from the old project.
4. (Optional) Add any custom SSL certificates you have.
5. Update your DNS provider's records to point to the new site. See more on [setting custom domains](https://docs.upsun.com../domains/steps.md).

It may take some time for the DNS change and SSL change to propagate.
Until it does, some browsers may not see the new site or may get an SSL mismatch error.
In most cases that resolves itself in 1--3 hours.

## 9. Remove the old project

Once the new project is running and the DNS has fully propagated, delete the old project.

## Alternative process

We have open-sourced [the Upsun cloning tool](https://github.com/upsun/clonsun), which allows you to clone a project from one region to another. This cloning tool helps you migrate most of your project assets from one region to another with some remaining manual steps like moving your domain names from one region to the other (or at the CDN level) and update your DNS records.

We also have [the Upsun converting tool](https://github.com/upsun/convsun), which allows you to change existing configuration files to another format. It converts details from files like `services.yaml` and `routes.yaml`, and generates a new `config.yaml` file. This streamlines the conversion process by significantly reducing the manual effort required to adapt your app’s infrastructure setup.

**Note**: 

To learn more about the converter tool and how it works, read the [converting projects](https://docs.upsun.com/learn/tutorials/migrating/from-fixed.md) page.

Although not directly supported by Upsun,
an agency named [Contextual Code](https://www.contextualcode.com/) has built a bash migration script.
This script automates most common configurations.
If your site is a typical single app with a single SQL database,
the script should take care of most of the process for you.

See more at the [Upsun Project Migration repository](https://gitlab.com/contextualcode/platformsh-migration).