How To Migrate Umami From One Server To Another

No Comments
Modified: 18.10.2022

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!

Requirements

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:

Server icon

VPS Hosting Course

Learn everything you need to know about servers and hosting your own applications!

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.

Need help or want to share feedback? Join my discord community!

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).

KOFI Logo

If this guide is helpful to you and you like what I do, please support me with a coffee!

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.

PostgreSQL

  1. check in the browser if everything works as expected (no websites there)
  2. move the backup file to the volume folder of umami-db backups (for me /var/docker/umami/backup/)
  3. 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.

Conclusion

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!

Discussion (0)

Add Comment

Your email address will not be published. Required fields are marked *