How to Migrate datadirectory from NC to NCP?

Hi, I am trying to migrate from Nextcloud to NextcloudPi. I was looking for a tutorial for the easiest and most foolproof way to do this, and didn’t find one. (If you have a good one, can you post it?)

However I did find a good tutorial for how to migrate from Nextcloud to AIO, and I’m hoping that the procedure works the same? Here it is modified from the original to match what I am expecting from NCP:

Migrating Files

The procedure for migrating only the files works like this:

  1. Take a backup of your former instance (especially from your datadirectory, see 'datadirectory' in your config.php)
  2. Install Nextcloud NCP on a new server/linux installation, enter your domain and wait until it is up and running
  3. Recreate all users that were present on your former installation
  4. Take a backup using Nextcloud NCP’s built-in backup solution (so that you can easily restore to this state again)
  5. Put into Maintenance Mode
  6. Restore the datadirectory of your former instance: for /path/to/old-nextcloud/data/ run sudo cp --follow-link /path/to/old-nextcloud/data/. /path/to/current-nc-data/ Note: the /. and / at the end are necessary. (Anyone wiser than me can explain why they are necessary)
  7. Next, run sudo chown -R www-data:www-data /path/to/current-nc-data/ and sudo chmod -R 750 /path/to/current-nc-data/ to apply the correct permissions. – There is also an nc-fix-permissions, but I did not try it.
  8. Disable Maintenance Mode
  9. Run sudo -u www-data php /var/www/nextcloud/occ files:scan-app-data && sudo -u www-data php /var/www/nextcloud/occ files:scan --all in order to scan all files in the datadirectory. There is also an nc-scan, but I did not try it.
  10. If the restored data is older than any clients you want to continue to sync, for example if the server was down for a period of time during migration, you may want to take a look at Synchronising with clients after migration below.

Synchronising with clients after migration

From Restoring backup — Nextcloud latest Administration Manual latest documentation

By default the Nextcloud server is considered the authoritative source for the data. If the data on the server and the client differs clients will default to fetching the data from the server.

If the recovered backup is outdated the state of the clients may be more up to date than the state of the server. In this case also make sure to run sudo -u www-data php /var/www/nextcloud/occ maintenance:data-fingerprint command afterwards. It changes the logic of the synchronisation algorithm to try an recover as much data as possible. Files missing on the server are therefore recovered from the clients and in case of different content the users will be asked.


The usage of maintenance:data-fingerprint can cause conflict dialogues and difficulties deleting files on the client. Therefore it’s only recommended to prevent dataloss if the backup was outdated.

If you are running multiple application servers you will need to make sure the config files are synced between them so that the updated data-fingerprint is applied on all instances.

–End of documentation adapted from AIO

I just ran through this procedure, and it worked for me. Still, I’d appreciate any of the forum ‘pros’ to look it over, use at your own risk, etc.,

Let me know what you think and I will update this post with any corrected information.

I really appreciate you effort to improve the docs :handshake: but please walk through the guide yourself before you post some “guide” where users might reach through search engines and potentially break their system. I unlisted the topic so far - let me know if you had a chance to test the procedure and confirm it works as described.

OP confirms the guide works. listed the topic again.

Hi, thanks for your wise words. I was hoping to get some feedback on this procedure before I tried it.

I tested it just now, and it worked – I updated the text and it should be good as an actual reference now.

1 Like