The Database ist missing some indexes - how to uptdate the database

Hello,
i saw the message from nextcloud 23.0.3:

The database is missing some indexes. Due to the fact that adding indexes on big tables could take some time they were not added automatically. By running “occ db:add-missing-indices” those missing indexes could be added manually while the instance keeps running. Once the indexes are added queries to those tables are usually much faster.

Missing index "fs_id_storage_size" in table "oc_filecache".
Missing index "fs_storage_path_prefix" in table "oc_filecache".
Missing index "properties_pathonly_index" in table "oc_properties".
Missing index "job_lastcheck_reserved" in table "oc_jobs".

My question as a newbie with databases:
My nextcloud ist running on a Strato V-Server - Ubunto 18.04 with Plesk - i can access via Putty

I found this command in the manual of nextcloud
https://docs.nextcloud.com/server/22/admin_manual/maintenance/upgrade.html?highlight=occ%20db%20add%20missing%20indices

$ sudo -u www-data php occ db:add-missing-indices

I think i have to do the following:
Go in my nextcloud directory and swith maintenance mode on:
root@h2xxxxx3:/var/www/vhosts/stxxxxz.de/nextcloud# sudo -u www-data php occ maintenance:mode --on

Datebase update:
root@h2xxxxx3:/var/www/vhosts/stxxxxz.de/nextcloud# sudo -u www-data php occ db:add-missing-indices

Maintenance mode off
root@h2xxxxx3:/var/www/vhosts/stxxxxz.de/nextcloud# sudo -u www-data php occ maintenance:mode --off

Is that right? I am afraid of breaking the database

that’s the correct command.

where www-data is your webuser.

1 Like

www-data is the user that nextcloud is running as. This is typical of most baremetal setups, but you should check the ownership of the nextcloud files to be sure. I’m not entirely sure how plesk sets it up.

With that said, I think you need to cd to that directory and then run the command

cd /var/www/vhosts/stefan-franz.de/nextcloud
sudo -u www-data php occ db:add-missing-indices

breaking down the command,
sudo runs with superuser permissions
-u specifies the user to run the command
www-data this is a web user for most installs
php call the PHP binary (if PHP is not in your path it will complain it can’t find it)
occ owncloud/nextcloud command line interface
db:add-missing-indices adds any missing indexes to the nextcloud database

basically, if you cd to the directory and run that command, it’ll either work, or give you an error message on why it can’t run that command. I can’t think of any way it would break your database.

3 Likes

Hello, thank you for your answers.
Right now i edited my first post because i found out how it works…but can confirm someone of i i’m right?

You don’t need to turn on maintenance mode, it won’t hurt anything if you do, but it’s not necessary.

I think if the message has gone all is fine.

root@h2937523:/var/www/vhosts/stefan-franz.de/nextcloud# sudo -u www-data php occ db:add-missing-indices
Cannot write into “config” directory!
This can usually be fixed by giving the webserver write access to the config directory.

How can i do it?

Hopefully it is this

directory:
/var/www/vhosts/stefan-franz.de/nextcloud/config
file:
/var/www/vhosts/stefan-franz.de/nextcloud/config/config.php

Yes, there is a config. But what do i have to edit, to make writeable?

The directory and file must be owned from your webserver user www-data. But i do not know if this is the reason for your error message.

pls make sure that www-data really is YOUR webuser.

Who owns nextcloud directory? ls -lar will show you

1 Like

Im with root over putty on my V-Server at Strato.
That is my own server and the nextcloud is the only app / web application on this.

root@h2937523:/var/www/vhosts/stefan-franz.de/nextcloud# ls -lar
insgesamt 172
drwxr-xr-x 3 stefan-franz psacln 4096 Apr 24 2021 .well-known
-rw-r–r-- 1 stefan-franz psacln 382 Mär 21 13:05 version.php
-rw-r–r-- 1 stefan-franz psacln 119 Mär 29 06:13 .user.ini
drwxr-xr-x 2 stefan-franz psacln 4096 Mär 29 06:11 updater
drwxr-xr-x 3 stefan-franz psacln 4096 Mär 29 06:10 themes
-rw-r–r-- 1 stefan-franz psacln 2452 Mär 21 13:02 status.php
-rw-r–r-- 1 stefan-franz psacln 26 Mär 21 13:02 robots.txt
drwxr-xr-x 4 stefan-franz psacln 4096 Mär 29 06:10 resources
-rw-r–r-- 1 stefan-franz psacln 5340 Mär 21 13:02 remote.php
-rw-r–r-- 1 stefan-franz psacln 3139 Mär 21 13:02 public.php
drwxr-xr-x 2 stefan-franz psacln 4096 Mär 29 06:10 ocs-provider
drwxr-xr-x 2 stefan-franz psacln 4096 Mär 29 06:10 ocs
drwxr-xr-x 2 stefan-franz psacln 4096 Mär 29 06:10 ocm-provider
-rw-r–r-- 1 stefan-franz psacln 283 Mär 21 13:02 occ
drwxr-xr-x 6 stefan-franz psacln 4096 Mär 29 06:10 lib
-rw-r–r-- 1 stefan-franz psacln 3456 Mär 21 13:02 index.php
-rw-r–r-- 1 stefan-franz psacln 156 Mär 21 13:02 index.html
-rw-r–r-- 1 stefan-franz psacln 3442 Mär 29 06:11 .htaccess
drwxr-xr-x 2 stefan-franz psacln 4096 Apr 24 2021 data
-rw-r–r-- 1 stefan-franz psacln 6050 Mär 21 13:02 cron.php
drwxr-xr-x 22 stefan-franz psacln 4096 Mär 29 06:10 core
-rw-r–r-- 1 stefan-franz psacln 34520 Mär 21 13:02 COPYING
-rw-r–r-- 1 stefan-franz psacln 3924 Mär 21 13:02 console.php
drwxr-xr-x 2 stefan-franz psacln 4096 Mär 29 08:05 config
-rw-r–r-- 1 stefan-franz psacln 19327 Mär 21 13:02 AUTHORS
drwxr-xr-x 55 stefan-franz psacln 4096 Mär 29 06:11 apps
drwxr-xr-x 44 stefan-franz psacln 4096 Mär 29 06:10 3rdparty
drwx–x— 9 stefan-franz psaserv 4096 Mai 25 2021 …
drwxr-x— 15 stefan-franz psaserv 4096 Mär 29 06:13 .
root@h2937523:/var/www/vhosts/stefan-franz.de/nextcloud#

Please improve your linux knowledge or buy a Managed Nextcloud.

All of the directorys and files /var/www/vhosts/stefan-franz.de/nextcloud must be owned from www-data.

From root:
chown -R www-data:www-data /var/www/vhosts/stefan-franz.de/nextcloud
(on your own risk)

Read manual:
man chown

I’m improving my linux knowledge…all my Laptops are running with Linux Mint

Can i use the Database command with me as user?:
/var/www/vhosts/stefan-franz.de/nextcloud# sudo -u stefan-franz php occ db:add-missing-indices

The files above show that stefan-franz is the user…isn’t it?

You can do a lot. Maybe your linux server can also make coffee. But it makes no sense above all. Perhaps you can also rename your root user to stefan. Why don’t you do that? Yes, it is pointless.

Linux uses technical users for technical features. Nextcloud is a web application and then www-data is used because it is the default technical user for webservices.

Have you ever read an installation guide for Nextcloud? Did you understand every step or do you only cut-and-paste? On a real problem you will maybe lost your whole Nextcloud.
https://www.howtoforge.com/how-to-install-nextcloud-on-debian-11/

You can buy a Managed Nextcloud with 500 GB for your own subdomain for 5 euro a month. You have to take care of the backup of the data or pay a few euros extra.

Thank you for your answer. I installed it with the Wizard of Plesk / Ubunto 18.04 and i was proud of me, to was able to run it.

And i have 1,5 TB - at the moment about 800 GB Data. Synchronized with many PCs and Laptops in my company here. And many shared Links in my Online Academy where the Nextcloud works as a file server.

A changing of it needs at least 4 Weeks working time for me to adjust all devices and synchronize all…and create new shared links…no sorry.

What i search is a workaround for the database. But Nextcloud works fine and the only i use is as File, Contact, Calender and Task Cloud. If it’s not able to adjust it, i think it’s no problem at the moment.

And i don’t want that other persons are able to look in my cloud…so i want to use my own server. :wink:

are you aware of the fact that every admin of your hoster would be able to look into your data you have stored there?

a hosted (and most prolly even shared) instance is never really your OWN. You rented it. A rented car or house or whatever is never really your OWN.
Owning your data completely can be achieved by hosting it on your own device.

Well if I remember it correctly… the owner of your apache-folder should be your webuser. So who owns your apache?

Perhaps the rights are sufficient because of the group psacln.

But you wrote Ubuntu 18.04 LTS.
In further Nextcloud versions it will not longer be supported.
I hope you know an upgrade path.
Hopefully the “Wizard of Plesk” supports you.
Install is easy, upgrade and maintenance not.

I rent a V-Server at Strato. There es a environment where only the admin has access to it.
And the admin is me.
Strato is only able to delete the 1,5 TB virtual place and i can reinstall. But Strato has no access to my server and neither to my Nextcloud.

Help - i have a intern Server - Error - my Nextcloud is standing after this command:

chmod 0644 /var/www/vhosts/stefan-franz.de/nextcloud/config

Interner Serverfehler

Der Server konnte die Anfrage nicht fertig stellen.

Sollte dies erneut auftreten, sende bitte die nachfolgenden technischen Einzelheiten an Deinen Server-Administrator.

Weitere Details können im Server-Protokoll gefunden werden.

How can get the rights again as here:
root@h2937523:~# ll /var/www/vhosts/stefan-franz.de/nextcloud/config
insgesamt 84
drwxr-xr-x 2 stefan-franz psacln 4096 Mär 29 08:05 ./
drwxr-x— 15 stefan-franz psaserv 4096 Mär 29 06:13 …/
-rw-r----- 1 stefan-franz psacln 1416 Mär 29 08:05 config.php
-rw-r–r-- 1 stefan-franz psacln 66350 Mär 21 13:02 config.sample.php
-rw-r–r-- 1 stefan-franz psacln 495 Mär 21 13:02 .htaccess
root@h2937523:~#