I deployed Nextcloud recently and populated it with a lot of files, users and groups. I figured that I used the wrong sharing mechanism. Thus, I would like to reset the (almost) the entire system: While I would like to keep registered users, groups, etc., I would like to reset (delete) all files of every user. In particular, all users should start with the same “blank sheet”, i.e with no files.
So I tested the first approach of deleting the respective user directories below the data directory.
Before deleting the user directory of user “foo”, I logged into the web interface of Nextcloud with user “foo” and uploaded a file “bar”. Next, I deleted {owncloud_install_dir}/data/foo, logged into the web interface of Nextcloud again with “foo” and the file “bar” was still visible.
Moreover, running occ files:scan --all now results in the following error:
Home storage for user foo not writable
I checked permissions of {owncloud_install_dir}/data/foo} and those are the same as the other user directories (owned by www-data). Finally, I cannot upload any files anymore with user “foo” via the web interface.
Seems like this is not a good approach to reset everything or I was doing something wrong.
creating the files subdirectory indeed solves the problem. Creating these subdirectories shall be no problem as I can write a quick shell script.
Indeed, your proposed solution seems to work as it clears all files of users. However, it seems like the process has to be executed in strict order of:
Delete user directory
mkdir -p {user}/files
occ files:scan --all
I validated it with a test user and will not conduct it with all operational users.
Sorry than i can not help. But perhaps cut-and-paste errors and configuration. Words often are not completely or with errors. You can change names in cut-and-paste before posting in the forum.
all fine thanks. Like stated previously, the error of failed uploads was solved by creating the files subdirectory and if one strictly adheres to the order of executing the individual steps, this approach solves all my problems posted initially.
I made the mistake of adding a mounted drive to my files directory and running occ files:scan --all. The result added a lot of unwanted files to my files and photos.
I roughly used your technique to mass remove the files that were inadvertently absorbed from the mounted drive… but with some modifications. It worked fabulously. Many thanks.
In the event someone else finds themselves in this situation, here’s what I did.
move the data/[user]/files directory outside of the data/ directory (best to keep it on the same drive if possible for speed).
remove the external storage(s)
execute occ files:scan [user]
move the files directory back into your data/[user]/ directory.
execute occ files:scan [user] again to add the files back to your account.
There was no need to remove the entire user directory.