# ODK Central - Changing domain names

**URL:** <https://forum.getodk.org/t/odk-central-changing-domain-names/37655>\
**Category:** Support\
**Tags:** odk-central\
**Created:** [May 13, 2022, 10:50am UTC](https://forum.getodk.org/t/odk-central-changing-domain-names/37655 "2022-05-13T10:50:26Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![danielpintosalazar](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/danielpintosalazar/32/28611_2.png) [@danielpintosalazar](https://forum.getodk.org/u/danielpintosalazar)\
**Post date:** [October 28, 2024, 7:29pm UTC](https://forum.getodk.org/t/odk-central-changing-domain-names/37655/10 "2024-10-28T19:29:07Z")

</div>

**Migrating ODK Central Server to a New Domain**

Hi, @Saad and @yanokwa. I migrated an ODK Central server hosted on a DigitalOcean droplet to a new domain. Here are the steps I followed:

**Steps to Migrate the Server**

**1. Generate a Snapshot**  
Create a snapshot of the current droplet where ODK Central is located. This will serve as a backup and a base for the new droplet.

**2. Create a New Droplet**  
Launch a new droplet using the snapshot created in the previous step.

**3. Update Domain in .env File**  
Modify the `.env` file to include the new domain names. Make sure that your DNS is pointing to the new IP address of the server.

**4. Rebuild Docker Containers**  
Run the following command to rebuild and start your ODK containers:  
`docker-compose up -d --build`

**5. Update Redis Databases**  
Update the Redis databases `central_enketo_redis_main_1` and `central_enketo_redis_cache_1` to reflect the new domain.

**Updating the Domain in Redis**

To update the domain, I used the following Bash script, based on this [tutorial](https://dev.to/kagundajm/odk-central-domain-change-a-painless-backup-and-restore-tutorial-4gpk). This script updates keys and values in Redis to replace the old domain with the new one. I recommend follow all steps of the tutorial, don't forget create a backup.

```auto
#!/bin/sh

OLD_DOMAIN="old-domain.com"
NEW_DOMAIN="new-domain.com"

keys=$(redis-cli -p 6379 KEYS "*")

for key in $keys
do
  if ["$(redis-cli -p 6379 type "$key")" = "string"]; then
    if echo "$key" | grep -q "$OLD_DOMAIN"; then
      new_key=$(echo "$key" | sed "s/$OLD_DOMAIN/$NEW_DOMAIN/g")
      redis-cli -p 6379 RENAME "$key" "$new_key"
    fi
  elif ["$(redis-cli -p 6379 type "$key")" = "hash"]; then
    existingRosaServer=$(redis-cli -p 6379 HGET "$key" "openRosaServer")
    if echo "$existingRosaServer" | grep -q "$OLD_DOMAIN"; then
      newRosaServer=$(echo "$existingRosaServer" | sed "s/$OLD_DOMAIN/$NEW_DOMAIN/g")
      redis-cli -p 6379 HSET "$key" "openRosaServer" "$newRosaServer"
    fi

    if echo "$key" | grep -q "$OLD_DOMAIN"; then
      new_key=$(echo "$key" | sed "s/$OLD_DOMAIN/$NEW_DOMAIN/g")
      redis-cli -p 6379 RENAME "$key" "$new_key"
    fi
  fi
done

```

Key Resources: [https://dev.to/kagundajm/odk-central-domain-change-a-painless-backup-and-restore-tutorial-4gpk](https://dev.to/kagundajm/odk-central-domain-change-a-painless-backup-and-restore-tutorial-4gpk)

---

_[View the full topic](https://forum.getodk.org/t/odk-central-changing-domain-names/37655)._
