How To Migrate Umami From One Server To Another
Do you want to migrate your Umami from one server to another? In this post, I will show you how to do so without losing your data! For that, we will first look at some requirements and then I will show you everything step-by-step, with two different approaches!
For the instructions in this post, there are some requirements. The first and most important one is that your current instance runs using Docker. The reason is that moving from one system to another should work seamlessly and I did not look at how to set umami up without docker. The other requirements are:
- You need two systems with docker installed
- One system needs a current instance of umami
- You know where you can find the current volumes (if not inform yourself before to make the process easier)
That’s it, if these requirements are fulfilled I will show you how to migrate your current umami instance.
Only migrate Umami data
Only migrating the data is my recommended way of migration, because the volumes of the database are really big, and it takes a long time to create an archive of them and then move them to another host.
To get the data you should set up an automated backup mechanism that I explained in this post here. I would recommend setting it up on both hosts and after you finished come back here (The whole setup, so that you have a running umami instance.)
In case you freshly set up the backup mechanism you should change the variable
SCHEDULE of the pg-backup container to something like
0 * * * *. But instead of the 0, you change it to one minute ahead of your current time.
Doing this will create a backup of the current data and you can use this data for the migration.
Now let’s move the latest backup to the new host. It can be found in the location of your pg-backup volumes inside
/var/docker/umami/backup/postgres/last/ (for me).
Now move the file to the new system using scp or an application like WinScp. After you moved the file you have to import it into the database. For that follow the following steps:
Before these steps build all containers by running
docker compose up -d umami-db umami.
- check in the browser if everything works as expected (no websites there)
- move the backup file to the volume folder of umami-db backups (for me /var/docker/umami/backup/)
docker exec -it umami-db bash -c "zcat /var/lib/postgresql/backup/<backup-file>.sql.gz | psql --username=umami --dbname=umami -W"
With that, your data should be migrated from one host to another!
Migrate Umami using Docker Volumes
Migrating Umami by moving the volumes from one host to another is probably the simpler, but the more time-consuming method. The idea is that you first create a zip archive of the needed volumes of the container, then download these archives and place them in the needed location on the other host.
For example, in my instance, I would create an archive of the directory
/var/docker/umami and move it to the host also in the same directory
/var/docker/umami and then run
docker compose up -d to create the container instances.
In this post, you learned how to migrate your Umami instance from one host to another and I hope it worked flawlessly for you. If you have any questions feel free to send me an email or ask through the comments!
In case you liked this post consider subscribing to my newsletter to get monthly updates on all my posts!