Nextcloud migration

This isn’t really going to be very interesting, but I like to write things down whenever I run into an issue on the off chance that I’ll run into it again at some point. Basically I was migrating my Nextcloud instance and ran into a problem. The last time I did this the steps were very straightforward and I didn’t even look at any documentation for it. I basically just did the following

  1. Create a dump of the Nextcloud database with sudo -u postgres pg_dump nextcloud > /var/nc.sql
  2. Copy the data folder to the new machine
  3. Copy the web root folder to the new machine
  4. Install all dependencies on the new machine
  5. Setup the database user and a blank database on the new machine
    1. CREATE DATABASE nextcloud TEMPLATE template0 ENCODING 'UNICODE';
    2. CREATE USER nextcloud WITH PASSWORD 'password';
    3. GRANT ALL PRIVILEGES ON DATABASE nextcloud TO nextcloud;
  6. Import the database dump with sudo -u postgres psql nextcloud < /root/oldvps/nc.sql
  7. Setup nginx again and the domain
  8. Setup the cron job

After that the instance was running on the new machine exactly where it left off on the old one. This time however this didn’t work. I got the instance to run but downloading certain files just wouldn’t work. It’d get an error page and the log contained an error that led me to this issue. As it turns out the encryption module was causing issues and apparently there’s no good fix for that. Thankfully I still have all my keys and the old instance so the solution for me was pretty simple: Just decrypt all the files via the command line tool. I had to do this on the old instance however because it somehow didn’t work on the new one. The decryption process is basically just running sudo -u www-data php occ encryption:decrypt-all. After that I copied over the data folder again and I could download the files that previously caused issues because they were encrypted. I also ended up disabling the encryption module because I don’t want to deal with more issues in the future and since the files can be easily decrypted it doesn’t really add any value.

But that wasn’t enough. While I could download the files just fine via the web interface the desktop client was still having trouble. It seemed like the desktop client was still convinced that the files were encrypted which caused the synchronisation to fail with a simple “Connection Closed”. Searching for this issue didn’t bring up much other than many other people having the same issue, but none of them seemed to be related to encryption. First I renamed both files_encryption folders in the root /data folder and in the user folder to files_encryption.old. This didn’t seem to fix the issue, but after running sudo -u www-data ./occ files:scan --path="/<my_username>/files" the problem solved itself.

TL;DR: The encryption module caused issues with migrating the instance so I’d advise against using it for local storage. So the data should be decrypted with sudo -u www-data php occ encryption:decrypt-all before migrating and then once the migrated instance is up and running the user files should be scanned again with sudo -u www-data ./occ files:scan --path="/<my_username>/files". Thankfully there’s only one user for me and I still had the original instance so this wasn’t too problematic.

Tags:

Software · Misc