Nextcloud version (eg, 18.0.2): 15.07
Operating system and version (eg, Ubuntu 20.04): 16.04? 16.04.6 LTS
Apache or nginx version (eg, Apache 2.4.25): 2.4.18
PHP version (eg, 7.1): ??
The issue you are facing:
I am running into the issue of OC_FILECACHE and OC_STORAGES records not being deleted when you remove an External Storage from the system through the UI.
Because we had some very large shares (which we are not using anymore), OC_FILECACHE has grown to be excessively large and has caused disk space problems.
My question is – can I just delete the records for the deprecated External storages directly in MySQL? This seems like a couple of trivial delete statements (one for each table, records corresponding to the same storage ID). Or will this corrupt the system somehow?
I followed number of post here and on github, unfortunately I have no references by hand. There is a known bug/misconception in nextcloud which turns into issue
storages, most often related to external storage used by multiple users is indexed multiple times
storages removed from NC config remain in DB (check oc_storages DB table)
records in oc_filecache table remain there (at least until corresponding storage is removed/or forever)
there was an issue on github discussing this more in depth and it looks there is an improvement now filecache records removed by occ files:scan --all/files:cleanup
at least for me running NC 19.0.8 following procedure helped:
enable external_files app (was removed earlier due to performance issues)
remove all configured storages
some external storages are still listed in oc_storages table
review this records select * from oc_storages where id like 'smb:%'
review this records delete from oc_storages where id like 'smb:%'
run occ files:cleanup
as a result it removed 160k stale records from file cache.
running ALTER TABLE oc_filecache FORCE;
returned free space as described here