In a previous article, I evaluated migrating to YunoHost, and after a year of trying my own solutions for self-hosting I’ve come back to YunoHost and I’ve finally found success! Now I enjoy the benefits of easy maintenance provided by YunoHost and I can spend less time doing sysadmin/devops on my free time.

What drove me to revisit YunoHost is the desire to add a new service and a add a friend of mine as a new user so we can collaborate. This made me realize how inflexible my self-hosting setup was at the time. Although my methods evolved to be fairly minimalistic, it was still time consuming to add a new service and a new user would have to be setup for each service.

Upon reflection, I had a hunch that my assumption on how to migrate the database were inaccurate. Instead of trying to restore data over an existing database as I did in the past, this time I wanted to wipe clean the database and do a full restore.

This time I installed YunoHost 3.5.2 on Debian 9 (Stretch) and was pleasantly surprised that a the issues I ran into earlier had been resolved. I only needed to migrate NextCloud and Matrix Synapse, both officially supported YunoHost applications. Choosing to focuse on Synapse first, I setup my username on YunoHost to be the same as my Matrix username (completely lowercase).

To get access to PostgreSQL on the YunoHost server, I ran the following as admin:

1
2
sudo su postgres
psql

Once I had a SQL client prompt, I ran the following SQL statements:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
SELECT pg_terminate_backend(pid)
  FROM pg_stat_activity
  WHERE datname = 'matrix_synapse';

DROP DATABASE matrix_synapse;

CREATE DATABASE matrix_synapse
        ENCODING 'UTF8'
        LC_COLLATE='C'
        LC_CTYPE='C'
        template=template0
        OWNER matrix_synapse;

This wiped the existing matrix_synapse database and recreated it. The CREATE DATABASE statement is taken from the Matrix Synapse documentation.

On the old host, I dumped the database by running the following:

1
pg_dump -Fc synapse -f synapse.dump

Then on the YunoHost server, I restored the database by running the following:

1
pg_restore --no-owner --role=matrix_synapse -d matrix_synapse synapse.dump

Finally, I used rsync to copy the files from the old host to /var/lib/matrix-synapse on the YunoHost server.

Testing this with a client confirmed that it worked and I found out a few things of note:

  • Authentication is handled by LDAP, your username just needs to match the one found in the Synapse database you migrate.
  • Authentication becomes case-sensitive with LDAP. Ensure you enter your username as lowercase in our client if your username is lowercase.

Reading the YunoHost Synapse documentation, I found that I need to open a port range in the firewall to allow connections to the turnserver and enable voice and video. This was something I was never able to configure correctly myself, but I was able to enable this easily on YunoHost.

Since only myself and my wife used NextCloud at the time, it was easy enough to migrate to NextCloud by setting up a client and copying the files over. Using the Shares view in NextCloud helped me rebuild the sharing relationships. For the calendar and contacts we simply exported from the old server and imported into the new one. For the News app, we exported to OPML and imported into Tiny Tiny RSS in YunoHost.

YunoHost made it easy for me to add my friends as users and it simplifies it so there’s just one username and password for all services. They also get a dashboard where they can view the services they can access as well as change their own password. I created a private wiki to document the services I’ve made available and guides for how to setup clients for connecting to Matrix and NextCloud.

YunoHost is easy to setup and makes it easy to manage a small handful of users and services. I can even create multiple instances of services and make use of this by having sevaral wikis for different purposes. YunoHost also provides a backup feature that’s easy to use.

YunoHost is a huge time saver and I’m looking forward to moving onto my next project.