Successfully moved to a new server!

ple relentlessly adding features to yunohost and supporting apps, I managed to move my self-hosted family site to a new server !

The situation
I am happily hosting the photos, emails and documents of my family into a server managed by yunohost.

I am doing this to keep control of everything that matters to me, avoid seeing my personal content being used wrongfully, and as well avoiding the risk of losing everything in case my account gets banned or locked by the gafams.
To be honest, I am doing this as well because as an IT guy, it’s quite fun to do it :slight_smile:

I’m leveraging an online server in a public hosting company, and installed Debian & yunohost there. Then installed yunohost managed apps I needed. On top of that, I’ve migrated a few of my projects (dont-code, cac-proxy, ng-xtend ) to yunohost and I’m maintaining mongo-express as well.

Sadly, this server is limited in disk size (only 1TB) and speed (only HDD, no SDD). So I decided to migrate everything to a new, more powerful server.

What do I manage through yunohost ?
There is enough material for another thrad, but after trying various solutions, I found yunohost was really covering my needs, especially the handling of multiple domains and subdomains, the number of already packaged applications and the fact that yunohost manages the full lifecycle of an application, including upgrades & backups.

So, what apps do I have installed ?

Nextcloud
It’s the main application here, taking care of photos/videos, all documents, private or shared amongst the family. This can be detailed in another thead but basically with Memories plugin, the Nextcloud mobile apps, the linux Nextcloud client, onlyoffice / collabora office, great support for sharing, this is good enough to replace Google drive & Google Photos.
I have around 300GB of pictures / videos there, which are automatically synchronized into my laptop (realtime backup) and backup into another server every week (thanks to yunohost backup features).

Email:
I bought my own domain name, and yunohost simply enable me to use it for my emails and the ones for my family. Thanks to it’s comprehensive Diagnostic tool, it helps you configure properly domain records and avoid any issues with spam.
I was scared a bit scared at first to use my own email domain, but didn’t face any issues or rejections. Now it’s my main email account.

OnlyOffice
Collabora Online
I couldn’t decide which application to use for editing documents, so I installed both. They are very well integrated with Nextcloud, all documents are stored in it, can be shared, and so on…

Sogo
For my emails, yunohost runs Imap / pop3 server by default so I most of the time use k-9 mail on my smartphone (it works very well), but I wanted to be able to use a webmail as well. Hence I installed Sogo in yunohost and it immediatly worked with multiple users and email accounts. Simple, nice and it works well !

Borg Backup
This one is crazy ! I bought a small online backup disk, with borg server installed there, and thanks to the yunohost integration with Borg, I automatically backup all my apps every week there.
Borg only stores the modifications, so the backup size stays manageable. And Yunohost backups each application separately, hence you can restore them one by one.

Adguard Home
My home is now using Adguard as a “ad-less” dns server, effectively blocking a lot of them. My wifi router is connected to it, and around 30% of the domain name requests are being cancelled by Adguard.

Matomo
For my opensource projects, dont-code and ng-xtend, I found Matomo is very good at providing statistics. It’s a great replacement of Google Analytics.

Cors-proxy
A small proxy I’ve developed and migrated to yunohost. It is used to bypass cors barriers and connect one web application to another server. I’m using it to get prices of shops for the Dont-code commerce application.

Dont-code services
A set of Java developed services allowing Dont-code web applications to manage projects and their data in a Mongo database. I have installed multiple instances of them, each mapped to a different domain.

MongoExpress
With it you can access your Mongo database, which I’m using for Dont-code project & data. This is another application I’m maintaining for yunohost.

Monitorix
Keep monitoring your server, displays any kind of graph you need, and alerts you when something goes wrong. Very nice utility.

Several static websites
I have several static websites installed as well, thanks to “my web app” application in Yunohost. Each are managed independently with their own sftp access, backups

How to migrate them to the new server ?

Despite all the help provided by yunohost, you need a bit of planification for the migration to be successfull.
Neither do you want to lose emails or photos of any of your family members, nor lose backups. Additionally, you want to keep the nextcloud mobile app working with the new server, and so on…

In a nutshell, the overall process I followed was this one:

  • First, configure the router to NOT use your adguard instance anymore. You don’t want to lose internet access in the middle of the migration !
  • Enable SFTP access to your admin user in the source server. This is done in the user configuration panel of yunohost admin. You’ll use this to transfer backups to the new server.
  • Then, install yunohost in the destination server. Run the postinstall configuration with a random domain name, and the same admin user / password account. This will be replaced by the system restore, but that will simplify a lot the migration.
  • Backup / restore system settings
    • In yunohost admin interface, go to Backup / Local / new local backup. Here uncheck everything except “system config”.
    • Once the backup done, you should see it in /home/yunohost.backup/archives directory.
    • From the new server, SFTP to the old server, and simply copy this archive at the same location
    • Then in the new server admin console, you’ll see the backup. Just restore it.
    • I then restarted the new server, I’m not sure it was necessary, but I found it safer.
  • Now you’ll see the new server have all users, domains configured !
    But the domains are still mapped to the IP address of the old server, so everything is still run by the old server. It’s only when changing the dns info in your domain registrar that the new server will be used.

The good thing is that you can switch any domain independently, allowing for a progressive upgrade. The only difficulty is with the emails, if you are receiving them from multiple domains, there may be some errors while a domain is migrating.As it’s just a family server, I thought it was ok with some hiccups on emails.

  • You can then do the same migration / restore with the accounts data (home/users) of your users. I know during the migration nobody in my family will update files in their home directories, so it was safe to do it without particuliar precautions. This can be much more tricky if you have unknown users.
  • Then, I migrate applications by domain / subdomain
    • For each app in a single domain/subdomain, backup them up locally using yunohost
    • SFTP them to the new server
    • Restore them in the new server
    • Change the DNS settings in your registrar to the IP address of the new server.

This works well for most of applications, where between the backup / restore and the dns change takes effect, you have almost no data written. But for emails and Photos, you don’t want to lose anything, so you need to take extra steps.

  • For emails:
    You can control when you send emails, but anyone can receive emails at anytime. If the old server is receving emails during the migration / restore process, then you may loose them.
    To avoid this, I just stopped the email service in the old server:

    • Stop postfix in tools / services
    • backup only emails
    • restore them to the new server
    • switch the DNS to the new server.
      I then connected my mobile email app, it automatically (thanks to the dns change) switched to my new server, and just checked I can send and receive emails there.
  • For photos:
    This one was the scariest, as I needed to move 300GB of data and migrate Nextcloud at the same time, with multiple applications connected to it (Nextcloud mobile apps, my laptop realtime backup…)
    Thankfully, both Nextcloud, yunohost and borg backup helps you there !

    • First, Nextcloud has a “Maintenance mode”, so in the old server, go to admin panel / applications / nextcloud, then configure pane, and check “activate maintenance mode”. This is automatically recognized by all Nextcloud apps, who switch to standby mode.
    • Second, yunohost stores photos and documents in a distinct & shared folder, that you can backup and restore independently of the applications.
    • So while Nextcloud is in maintenance mode, you are sure no documents or photos are being modified, then you can backup and restore both Nextcloud app and Multimedia files to your new server.
    • Restoring the 300GB of files to the new server went fine, although it took a long time to backup, transfer and restore.
    • However, restoring Nextcloud failed, because of a bad unicode character in its database !
    • This is due to the Memories plugin downloading world’s place names
      Troubleshooting - Memories
    • This was quite scary, because of this, the restore of Nextcloud completely failed. What could I do ? Documentation says I can remove the table from the backup file (a plain sql text) but I didn’t feel comfortable with it. I needed to remove all places information in a safe way.
    • So, in the old server, I just restarted a full reload of places data, knowing it will first delete the entries, and stopped the reload immediatly (to avoid inserting again the bad unicode)
    • Then backed up again Nextcloud and restored it in the new server.
    • It worked ! Nextcloud was now up and running to the new server, with all the users and photos !
    • I just had then to switch the DNS entries to the IP addresses of my new server, then uncheck the “maintance mode”, and that’s it.
    • The Nextcloud mobile app did have trouble reconnecting to the new server, but after a while, I could make it work.
    • I’ve just checked that no photos taken during the migration were missing, and new photos were correctly uploaded, then all was good.
  • Last step:
    Not to be forgotten! The server is backs up to a Borg instance, and you have to make sure it’s still working.

    • This was maybe specific to my configuration, but when creating the borg backup, my old server was using an old domain name, which was used to communicate through ssh to the backup server.
    • When I switched my old server to a new domain, the ssh kepts the old key with the old domain to manage backups.
    • But when using my new server, a new ssh key have been created, with the new domain name, and was used to push updates to the backup server. The backup server rejected the connection as it didn’t recognize the host.
    • Thanks to yunohost admin console, I have seen (in applications / borg backup / config ) that the Public key was different, and needed to be added in the backup server “known_hosts” file.
    • Once done, the backups were running smoothly from the new server.

Conclusion
In less than a few hours (spanning over a week-end), I could just migrate all my apps and data to a new server, with everything working again (but faster !).
This required some IT knowledge, even when everything goes smooth (which was not the case for Nextcloud), but overall this was much easier than expected.

And knowing I could get support from the yunohost community very quickly, made me confident to start this journey. I wanted to avoid this unless I was really in trouble, and let them work on their incredible solution !

I’ll be happy to precise some unclear points if asked to, but I hope this post-migration thread will help people running their yunohost services.

4 Likes

Thanks for detailing the whole process. I’m bookmarking this, will be helpful one day.

Same here. Thanks a lot!