After moving files to a new drive with rsync changes in web are not synced back to client

Hi! I have moved files from old drive to a new one with the help of rsync command.
By the result I lost all shares: this I restored manually.

The most challenging is that the syncing appeared to be broken: so, if I create a file in web it is not synced by the desktop client at local pc. However, it works back: when I create a file at local pc, it is synced at web.

How to fix the issue?

Could you please describe all steps you did with all exact command with theire arguments, exactly in the same order as you executed them?

That makes it easier to see what went wrong. Maybe you forgot or oversaw one step to get to your goal.


Hi! I have disconnected the server from network, created a new folder /media/data, chowned it with www-data, and ran the command
rsync -avh --progress --info=progress2 /media/nc/data/* /media/data

As I understand it was a mistake to use rsync instead of cp command?
What is the best way of transferring data from one storage to another?

Hi @knedlyk, using Rsync to move your data is recommended, but maybe you forgot to do something…
have you launched occ files:scan --all command ?
have set the new folder as a new data folder in Nextcloud?

Sure, I’ve launched scanning, changed the storage directory name in the config.php file.

So, I repeated again the scenario with the command cd /media/nc; tar cf - data | (cd /media; sudo tar xf - )

After moving to a new location I am still getting two major issues:

  1. lost shares
  2. broken syncing

When I am changing back to the old directory everything is fine.

So, the question, is there in the DB or somewhere else the absolute path to the data storage is indicated? Which may be other reasons?

Hi @knedlyk,

  • Have you set correctly this line in your config.php ? (/…/nextcloud/config/config.php)

‘datadirectory’ => ‘/var/www/nextcloud/data’,
→ ‘datadirectory’ => ‘/media/data’,

change the path to the new folder path

  • check the UNIX permission on the folder (read, write , execute) and the owner

  • then try these 2 commands :
    occ files:scan --all
    occ files:repair-tree

1 Like

Thanks a lot! So, what helped me a lot, as this explanation:

Unofficially moving the data directory can be done as follows:

  1. Make sure no cron jobs are running
  2. Stop apache
  3. Move /data to the new location
  4. Change the config.php entry
  5. Edit the database: In oc_storages change the path on the local::/old-data-dir/ entry
  6. Ensure permissions are still correct
  7. Restart apache

In particular #6.

1 Like

Yes. That’s why the process in the documentation has you either keep the same path (or a symbolic link in place to maintain it) or edit the oc_storages database table to update the path. Just changing datadirectory is not sufficient.

1 Like