I have setup ODK Central on a certain domain (e.g. abc.com), and now want the same installation to work under another domain (e.g. xyz.com) [Please note that it is a migration, and not an effort to run both in parallel at the same time]. The server and IP address remains the same, so I just need to map the old IP address to the new sub-domain. What changes do I need to make in Central configuration? Is it just the change in .env file, to update to new URL? I assume I would have to do 'docker-compose build' as well afterwards? Would it hurt the existing forms data present in the Central? Any other changes needed?
I haven't verified recently, but everything in Enketo is bound to the domain, so I'm pretty sure public access links (and maybe even previews) will not work if you rebuild with a new domain.
It's possible that re-uploading a new version of each form with an incremented version number will fix it, but I haven't tested that workaround.
Worst case scenario, you'll need to go into the Redis DBs at central_enketo_redis_main_1 and central_enketo_redis_cache_1 and manually replace the old domain name with the new. Not straightforward to do, but doable.
Hey, @Saad as @yanokwa mentioned only public access links and script which I created to download raw data from the server affected. And I rebuild them in my case I did not have any data loss on my side. One more thing, I am not using any other database server for maintaining the datasets.
Theoretically no. Central setup asks for domain name during installation and its also bound by SSL certificates. You 'may' setup a redirect from another domain, but the main domain will remain the same. You won't be able to replicate many things, especially the server address in the collect app associated with long form names.
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. 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.
#!/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