I updated my Nextcloud instance on my Ubuntu Server today from Major version 23 to 24 which ended in an error somehow. I was not able to fix the error at all, it completely broke my database (MariaDB) for some reason, MariaDB was not even able to run at all. I had to completely reinstall MariaDB and created a new Nextcloud Database. I triggered Installation process of Nextcloud again so that Nextcloud configures itself to run with the new DB instance. This worked fine and I have a fresh running instance of Nextcloud 24.0.3 now. However, the users are not showing of course. As the data of the users is still there on /var/www/html/nextcloud/data, I expected to fix this issue with occ files:scan -all, however it does not find the data of the users that Nextcloud is not aware of. This would not be a pity as the data in this Nextcloud is not important, however it also does not let me create a new user with the same name. So when I try to create a new user named Test for example, it won’t let me do so as user data folder Test is already existing. But I also cannot delete this folder manually on the CLI as Ubuntu wont let me - even as a root user. How to fix this situation? I already tried out everything that occ offers (Using the occ Command — Nextcloud 12 Server Administration Manual 12 documentation) but I cannot fix the situation with this command.
Thanks a lot for your support!
hi sorry to hear of your troublous. obviously the fact that you cannot change anything to directory Test even in CLI as root should raise red flags.
root in CLI or shell or console should have the ultimate and last access to the files. the fact that you cannot mv (move) this folder to Test_old should be resolved before you continiue resolving nextcloud issues.
please provide us some info on your linux knowledge.
if you need detailed custom commands please provide /etc/fstab, nc_installation/config/config php,
output of ls -la nc_data/
obviously replace nc_installation and nc_data with your own locations.
Hey, thanks for your answer.
Actually I just tried to touch/mv/rm files in the /var/www/html/nextcloud/data folder with standarad user + sudo, which did not work. I just tried out to switch to root user (which i normally avoid to use for given reasons) and with root, it let me do everything with the files. In theory, I could now move the files into a temp folder, delete the old user folder, create the accounts and move the files into these new user folders that Nextcloud will create during user creation. Do you think that this plan should work? If so, I will give it a try.
Sorry. But i think without the users in Nextcloud commands like
occ files:scan --all does not work. Also use the same directory/file-structure and set rights to e.g.
1 mv test test_old
2 create user test
3 mv test test_bak
4 mv test_old test
5 occ files:scan test
depending on how many users you have this might take some time.
your way is my 2nd suggestions
1 move all data to a secure location.
2 create all users
3 restore all data back to the users
3.5 check that permissions are correct
4 occ files:scan all
the fact that you do not have a backup of the database will result in shares not being shared anymore and contacts and calendar will be empty.
not nc related.
check into your sudo permissions why mv isn’t working for your user.
I just tried it out that way. However when creating a new user, it still says me the user is already existing. (Different error message, before it told me that there is already DATA for the user existing!) However, the user is NOT existing, as I can see in the WebGUI and when using occ. There must still be an old entry for those users somewhere - however, it is not in the database… If I can somehow remove this old entry, this way should work.
Btw: Calenders and Contacts are not important.
Just brainstorming… Secret and Instance ID in the config.php file under /var/www/html/nextcloud/config/ is still the same as in the old installation. Could this be problematic?
yes i would say a new installation would generate a new id.
I cannot help indepth as I’m on my mobile. but you can reset or get you id several ways.
anyways your instance id is the same as appdata_XXXXXX where xxxxxx is you instance id.
do you still have your old database?
is your new database with a different name?
Forget it, something truly magical just happened that I cannot explain!
I tried it again 3 times to create the account, always gave me the error message. Waited 1 Minute, refreshed the users page while still being logged into admin account. And then… Suddenly… There was my Account! For a reason I cannot understand! And even more strange: It has the old profile picture!
I copied my data/files that I had in the tmp folder into the subfolder /files again that was created after first login into that account, ran sudo -u www-data php occ files:scan --all and é voila - it’s working. Dunno why…
Big Thanks for this active community to support me during my problems!
I just hope that next update won’t destroy my system again.
maybe time to start creating a backup.
sometimes it helps to restart services.
glad your sorted out. have a nice day
I do not really understand your problem discussed in this thread.
But normally you must use backup (!!!) and restore. Test it with your existing system on a test server. I think “fresh installation” with “old data” was the problem. That is no normal backup-restore-path. Maybe you just got lucky and lose everything next time.
I will have more focus on backups in the future.
Just one more thing: Of course I made chown and chgrp of the folders i moved manually back to www-data, however I still cannot edit or delete/move the files I copied manually. Any ideas what else I could try out?
directory permissions are atleast 750 and files 640
try sudo -u www-data touch test.file in any user directory. this should verify that www-data has write access.
verify you can create directories as www-data user.
Just set chmod -R 770 * and this did the trick. Thanks a lot!
this results infiles being executable.
directories should have 750
files should be 640
you can get this as in the manual setting permissions
from your data directory run
sudo find . -type d -print0 | sudo xargs -0 chmod 0750
sudo find . -type f -print0 | sudo xargs -0 chmod 0640
type d = directory
type f = files
Are executable files a security issue? Or is it just “not as it should be”? Just to understand the problem. Thanks a lot for your hint.
sudo in the Ubuntu way. Ok i use Debian.
But i think the second sudo after pipe (
|) is not needed.
sudo find . -type d -print0 | xargs -0 chmod 0750
sudo find . -type f -print0 | xargs -0 chmod 0640
I think the full command is executed from “root”.
find . -type d -print0 | xargs -0 chmod 0750
find . -type f -print0 | xargs -0 chmod 0640