From Wiki


Mass import of files

Import all files to the data directory of the specified nextcloud user (user_id):

cd /usr/share/nextcloud/data/${myNextcloudUser}/files
rsync -av /backup_of_data/${myNextcloudUser}/files/. .
chown -R apache:apache .

Then you can import everything with the following command:

Important: use php71, or you get an error!

# for all users 
/usr/bin/sudo -u apache /usr/bin/php71 /usr/share/nextcloud/occ files:scan --all

# for the given user only
/usr/bin/sudo -u apache /usr/bin/php71 /usr/share/nextcloud/occ files:scan ${myNextcloudUser}

You should see something like this:

Scanning files for 2 users
Starting scan for user 1 out of 2 (username)
| Folders | Files  | Elapsed time |
| 28585   | 107801 | 02:11:30     |