☑ Moving installation to another OS?

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 12.0.2): 14.0.3
Operating system and version (eg, Ubuntu 17.04): Gentoo Linux (was Adélie Linux)
Apache or nginx version (eg, Apache 2.4.25): lighttpd 1.4.52
PHP version (eg, 7.1): 7.2.19

The issue you are facing:

I followed the documentation to create a backup, including the data dir and the database. I left the existing data in place, just to see if it would work when I switched OSes.

The thing is, Gentoo stores NC files in a different way than Adélie did. It’s organized for vhosts, which I don’t use. So, I worked around this by changing the docroot to /usr/share/webapps/nextcloud/14.0.3/htdocs, and Nextcloud mostly worked!

However, when I check logs, I see paths that don’t exist. Kind of expected due to the difference in OSes, but I’m not sure of the best way to proceed.

To clarify, I have NOT moved the data dir or app data. I intend to keep those in place. They are in /var/lib/nextcloud

What I’m thinking is there are two solutions: one is to dive directly into the database using pgadmin and correct the paths myself. I could probably do this in a few hours, depending on how poorly paths are managed internally. I was mistaken: it appears that no (or very few) absolute paths are present in the database.

The other solution is the one that’s typically peddled, “Reinstall”. However, if I reinstall, it will produce a different instance ID, and the backup DB won’t be able to be grafted onto that because there isn’t a tool to migrate or correct paths in a DB backup. Again, no real paths in the database; the occ tool gets commands added to it to aid migration as needed. I’ve spent considerable time setting up NC on the prior install, and the point of a backup is to be able to restore it.

How can I restore this backup on a different (but similar) OS, getting the same instance ID, the same share link IDs, and so on? I’m sure businesses are able to pull this off, so an individual should, too.

Is this the first time you’ve seen this error? (Y/N): n/a

Steps to replicate it:

  1. Follow the docs to do a backup
  2. Install the same NC version on a different OS
  3. Restore the backup
  4. Watch as some icons don’t show up, some scripts don’t trigger, and errors get spat out to the log. Most of NC works despite these errors, though.

The output of your Nextcloud log in Admin > Logging:

(I don’t think this is relevant since I’ve already explained the situation, but here ya go)

Error	Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0	2019-07-27T09:15:20-0700
Error	Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0	2019-07-27T09:15:20-0700
Error	Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0	2019-07-27T09:15:19-0700
Error	Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0	2019-07-27T09:15:19-0700
Error	Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0	2019-07-27T09:15:18-0700
Error	ResourceLocator can not find a web root (root: /var/lib/nextcloud/appstore/contacts, file: css/contacts/c925-7a27-style.css?v=2e20e2a4ee0070cb8198097823bcfcd4, webRoot: , throw: true)	2019-07-25T21:33:39-0700
Error	ResourceLocator can not find a web root (root: /var/lib/nextcloud/appstore/contacts, file: css/contacts/c925-7a27-style.css?v=2e20e2a4ee0070cb8198097823bcfcd4, webRoot: , throw: true)	2019-07-25T21:22:02-0700
Error	Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0	2019-07-25T21:20:44-0700
Error	Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0	2019-07-25T21:20:44-0700
Error	Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0	2019-07-25T21:20:43-0700
Error	Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0	2019-07-25T21:20:43-0700
Error	Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0	2019-07-25T21:20:32-0700
Error	Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_backupcodes" WHERE "user_id" = ?' with params ["zlg"]: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "oc_twofactor_backupcodes" does not exist LINE 1: SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_ba... ^	2019-07-25T21:05:32-0700
Error	Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_backupcodes" WHERE "user_id" = ?' with params ["zlg"]: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "oc_twofactor_backupcodes" does not exist LINE 1: SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_ba... ^	2019-07-25T21:05:32-0700
Error	Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_backupcodes" WHERE "user_id" = ?' with params ["zlg"]: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "oc_twofactor_backupcodes" does not exist LINE 1: SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_ba... ^	2019-07-25T21:05:32-0700
Error	Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_backupcodes" WHERE "user_id" = ?' with params ["zlg"]: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "oc_twofactor_backupcodes" does not exist LINE 1: SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_ba... ^	2019-07-25T21:05:31-0700
Error	Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_backupcodes" WHERE "user_id" = ?' with params ["zlg"]: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "oc_twofactor_backupcodes" does not exist LINE 1: SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_ba... ^	2019-07-25T21:05:31-0700
Error	Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_backupcodes" WHERE "user_id" = ?' with params ["zlg"]: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "oc_twofactor_backupcodes" does not exist LINE 1: SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_ba... ^	2019-07-25T21:05:31-0700
Error	Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_backupcodes" WHERE "user_id" = ?' with params ["zlg"]: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "oc_twofactor_backupcodes" does not exist LINE 1: SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_ba... ^	2019-07-25T21:05:28-0700
Error	Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_backupcodes" WHERE "user_id" = ?' with params ["zlg"]: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "oc_twofactor_backupcodes" does not exist LINE 1: SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_ba... ^	2019-07-25T21:03:38-0700
Error	Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_backupcodes" WHERE "user_id" = ?' with params ["zlg"]: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "oc_twofactor_backupcodes" does not exist LINE 1: SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_ba... ^	2019-07-25T21:03:37-0700
Error	Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_backupcodes" WHERE "user_id" = ?' with params ["zlg"]: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "oc_twofactor_backupcodes" does not exist LINE 1: SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_ba... ^	2019-07-25T21:03:37-0700
Error	Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_backupcodes" WHERE "user_id" = ?' with params ["zlg"]: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "oc_twofactor_backupcodes" does not exist LINE 1: SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_ba... ^	2019-07-25T21:03:36-0700
Error	Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_backupcodes" WHERE "user_id" = ?' with params ["zlg"]: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "oc_twofactor_backupcodes" does not exist LINE 1: SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_ba... ^	2019-07-25T21:03:36-0700
Error	Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_backupcodes" WHERE "user_id" = ?' with params ["zlg"]: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "oc_twofactor_backupcodes" does not exist LINE 1: SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_ba... ^	2019-07-25T21:03:36-0700
Error	Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0	2019-07-25T21:03:36-0700
Error	Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0	2019-07-25T21:03:35-0700
Error	Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_backupcodes" WHERE "user_id" = ?' with params ["zlg"]: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "oc_twofactor_backupcodes" does not exist LINE 1: SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_ba... ^	2019-07-25T21:03:35-0700
Error	Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0	2019-07-25T21:03:34-0700
Error	Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_backupcodes" WHERE "user_id" = ?' with params ["zlg"]: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "oc_twofactor_backupcodes" does not exist LINE 1: SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_ba... ^	2019-07-25T20:56:25-0700
Error	Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_backupcodes" WHERE "user_id" = ?' with params ["zlg"]: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "oc_twofactor_backupcodes" does not exist LINE 1: SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_ba... ^	2019-07-25T20:56:25-0700
Error	Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_backupcodes" WHERE "user_id" = ?' with params ["zlg"]: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "oc_twofactor_backupcodes" does not exist LINE 1: SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_ba... ^	2019-07-25T20:56:25-0700
Error	Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_backupcodes" WHERE "user_id" = ?' with params ["zlg"]: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "oc_twofactor_backupcodes" does not exist LINE 1: SELECT "id", "user_id", "code", "used" FROM "oc_twofactor_ba... ^	2019-07-25T20:56:24-0700
Error	Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0	2019-07-25T20:56:17-0700
Error	Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0	2019-07-25T20:56:16-0700
Error	Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0	2019-07-25T20:56:16-0700
Error	Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0	2019-07-25T20:56:16-0700
Error	Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0	2019-07-25T20:56:14-0700
Error	Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0	2019-07-25T20:51:19-0700

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'datadirectory' => '/var/lib/nextcloud/data',
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/usr/share/webapps/nextcloud/14.0.3/htdocs/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/lib/nextcloud/appstore',
      'url' => '/appstore',
      'writable' => true,
    ),
  ),
  'updatechecker' => false,
  'check_for_working_htaccess' => false,
  'htaccess.IgnoreFrontController' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'installed' => true,
  'instanceid' => 'ocoduo86ciwx',
  'passwordsalt' => 'REDACTED',
  'secret' => 'REDACTED',
  'trusted_domains' => 
  array (
    0 => 'files.zlg.space',
  ),
  'dbtype' => 'pgsql',
  'version' => '14.0.3.0',
  'overwrite.cli.url' => 'https://files.zlg.space',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost:5432',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextcloud',
  'dbpassword' => 'REDACTED',
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_from_address' => 'REDACTED',
  'mail_domain' => 'zlg.space',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'REDACTED',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'REDACTED',
  'mail_smtppassword' => 'REDACTED',
  'maintenance' => false,
  'data-fingerprint' => 'REDACTED',
);

(For reference, Adélie installs Nextcloud to /usr/share/webapps/nextcloud without version info since it’s a binary distro)

The output of your Apache/nginx/system log in /var/log/____:

Irrelevant here again since it’s the webserver and that part’s working fine. I could not find an error log for lighttpd (indicating that it hasn’t written one yet). /var/log/php-fpm.log contains no errors related to the nextcloud pool, too. This is squarely a NC internal thing.

For reference, here’s the top two levels of files for NC, as installed by Gentoo:

/usr/share/webapps/nextcloud/14.0.3 # tree -L 2
.
├── conf
├── config-files
├── hooks
├── hostroot
│   ├── cgi-bin
│   ├── error
│   └── icons
├── htdocs
│   ├── 3rdparty
│   ├── AUTHORS
│   ├── COPYING
│   ├── apps
│   ├── config
│   ├── console.php
│   ├── core
│   ├── cron.php
│   ├── data -> /var/lib/nextcloud/data/
│   ├── data-default
│   ├── index.html
│   ├── index.php
│   ├── lib
│   ├── occ
│   ├── ocm-provider
│   ├── ocs
│   ├── ocs-provider
│   ├── public.php
│   ├── remote.php
│   ├── resources
│   ├── robots.txt
│   ├── settings
│   ├── status.php
│   ├── themes
│   ├── updater
│   └── version.php
├── installed_by_webapp_eclass
├── server-owned-files
└── sqlscripts

22 directories, 15 files

(I moved the existing ‘data’ dir to data-default and symlinked data to /var/lib/nextcloud/data. It works.)

Thank you for any assistance you can offer. It’s becoming frustrating trying to maintain a restorable backup for NC.

EDIT: Advanced instructions are totally fine. I’m not afraid to get my hands dirty :slight_smile: In the mean time, I’m exploring NC’s database via pgadmin. So far I haven’t run into any paths yet. I’ll update this thread again if I find a solution.

EDIT2: I’ve crossed out some info that was wrong.

So I found a work-around.

This is a case that’s hit by the “second app dir outside of document root” bug, when ResourceLocator cannot find a web root. When I moved my apps to the default location and disabled/re-enabled them, the apps that were acting up (Contacts, Calendar, Deck) all worked correctly.

I’m not too pleased to have to consolidate my app dir, but it at least works. I took the opportunity to upgrade NC once I fixed this; I have an idea that I’ll try once I’m done upgrading (14 -> 15 worked well; 15 -> 16 might too!), then report back.

Here’s a list of bugs I found that helped me piece things together:

This is why I do all my work with sort of stuff from source, and not what’s offered from package managers. Not only do I know where stuff is at, but it’s also easier to migrate instances of Nextcloud. Storage locations are a bit opinionated. That way the opinion is mine and not that of the distro (or distros when switching)

1 Like

I too am coming to the same conclusion! Gentoo’s nice for building things from source, but webapps typically live in a single directory and you config the server from there. I’m sure the way they installed it is nice for virtual hosting, but this is just a personal/family cloud.

Yeah, management is really easy from installing from source. Nextcloud does a great job at making changes easy, migration easy, installation easy, etc. I think adding a distro’s spin just adds complexity where it isn’t even helpful. I’m sure if you ever wanted to, you could follow similar steps to what you’re doing now and do yet another migration (on the same host) from what’s offered in the package manager to the manual way. The updater is nice too. You can use the GUI one, or I use the command line sudo -u www php /path/to/nextcloud/updater/updater.phar