Restore database to new server with different DB credencials

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face: is for home/non-enterprise users. If you’re running a business, paid support can be accessed via 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:


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


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): 13.02
Operating system and version (eg, Ubuntu 17.04): Freenas 11.1 U4
Apache or nginx version (eg, Apache 2.4.25): nginx/1.12.2
PHP version (eg, 7.1): 7.2

The issue you are facing:
Is it possilbe to restore nextcloud from one server with a database user of user_A and pw_A to a new server with user_B and pw_B
Is this the first time you’ve seen this error? (Y/N):y

Steps to replicate it:

The output of your Nextcloud log in Admin > Logging:


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


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


There is no automated way, but it is not too hard to achieve:

  1. Do a database dump of (only) the nextcloud database.
  2. Copy database dump, data directory and best also Nextcloud installation directory to the new server.
  3. Create the desired database user and use it to import the database dump.
  4. Adjust database credentials within config.php.

That should do the job.

But of course only remove the old data after you verified that every part of Nextcloud is working as expected :wink:.

These are the steps I followed
Maintenance mode enabled
Stopping nginx.
copy fresh install config.php
Deleting old Nextcloud file directory…
Deleting old Nextcloud data directory…
Restoring Nextcloud file directory…
Restoring Nextcloud data directory…
Dropping old Nextcloud DB…
Creating new DB for Nextcloud…
Restoring backup DB…
Starting nginx.
Setting directory permissions…for db and files directories
replace old config with new install config.php
Updating the system data-fingerprint…
Maintenance mode disabled
reset admin password

Everything so far seems to work but when I go to a folder that I’ve shared with an email I just get a spinning circle. I guess the contact db didn’t copy over. After exporting the contacts from the old nextcloud and importing to the new one I still get the spinning circle.

How do I transfer the shares that I’ve done with an email to the new server?

I found the problem.
I used tar -cpzf to compress the directory and tar -xpzf to decompress.
When I tried again after switching to rsync -avx / rsync -Aax the share were present again.

I don’t know why buy subsequent restores didn’t get the prior share history with the rsync command as well. Turns out running the command ‘occ maintenance:repair’ restores the shares. Hope this helps someone else.