Nextcloud files permissions (not users files)

hi there !

context: Nextcloud v 31.0.5 (I think), self hosted on docker

some days ago my teammate noticed some nextcloud data files (not users files) were owned by root so he changed all to www-data
yesterday I noticed webdav/caldav sync was not longer working and I couldn’t remove a task from nextcloud directly

so I searched for correct permissions to restore but I broke Nextcloud even more (error 500) :smiley:

here are our permissions right now (on host):

$ ls -al nextcloud/
total 16
drwxr-xr-x  4 www-data www-data        4096 May 25 15:38 .
drwxr-xr-x 17 <my-user>  <my-user>         4096 Aug 19 10:18 ..
drwxrwx--- 16 www-data www-data        4096 May 25 15:38 data
drwxr-xr-x  6      999 systemd-journal 4096 Aug 24 10:26 db

I feel like something’s wrong with db directory permissions…

I already tried:

docker exec -u www-data <nextcloud-container-name> id (found 33)
sudo chown -R 33:33 nextcloud/data/
find nextcloud/ -type d -exec chmod 750 {} \;
find nextcloud/ -type f -exec chmod 640 {} \;

but what about db?

what else should we check?

thanks for your help!

OK I tried to init new data and db folders by renaming the existant ones to check what permission and owner files and folders should have.

I then set these permissions and ownership to my saved folders but it still doesn’t work :cry:
(and it’s more 664 for files and 755 for dirs)

EDIT:
docker ps shows db container is restarting
docker logs <nextcloud-db-container> shows a lot of errors

I searched about those db errors and my nextcloud is back alive! \o/ (even with task & cal sync working)

I still don’t get why changing permissions or ownership broke everything but we know we shouldn’t touch this :smiley: