All files from subfolders are gone after database migration

Support intro

Sorry to hear you’re facing problems. :slightly_frowning_face:

The community help forum (help.nextcloud.com) is for home and non-enterprise users. Support is provided by other community members on a best effort / “as available” basis. All of those responding are volunteering their time to help you.

If you’re using Nextcloud in a business/critical setting, paid and SLA-based support services can be accessed via portal.nextcloud.com where Nextcloud engineers can help ensure your business keeps running smoothly.

Getting help

In order to help you as efficiently (and quickly!) as possible, please fill in as much of the below requested information as you can.

Before clicking submit: Please check if your query is already addressed via the following resources:

(Utilizing these existing resources is typically faster. It also helps reduce the load on our generous volunteers while elevating the signal to noise ratio of the forums otherwise arising from the same queries being posted repeatedly).

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can. :heart:

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 33.0.3
  • Operating system and version (e.g., Ubuntu 24.04):
    • Arch Linux
  • Web server and version (e.g, Apache 2.4.25):
    • nginx 1.30.1
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • nginx 1.30.1
  • PHP version (e.g, 8.3):
    • 8.5.6
  • Is this the first time you’ve seen this error? (Yes / No):
    • Yes
  • When did this problem seem to first start?
    • When I upgraded to Nextcloud 33.0.3
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Archive
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • No

Summary of the issue you are facing:

After upgrading to Nextcloud 33.0.3 (from I belive it was 32) all the files stored in sub-folders on my account is now gone. If I go to the web interface all I see is a bunch of empty folders:

On my desktop, the desktop file syncing client have deleted all the files.

The nextcloud desktop app did not place the files in the recycle bin, or ask me before it decided to delete around 3000 files totalling 45 GB stuff I actually care about having and keeping on my desktop.

Steps to replicate it (hint: details matter!):

I have no idea how to replicate this. But the steps I took are roughly as I remembered them:

  1. Ran php updater/update.phar as the http user from the /srv/http/cloud folder repeatedly until I was at the latest version.
  2. Ran the ./occ maintenance commands as the http user for I belive it was some database indexes and such as recommended in the administration setting overview.
  3. Turned on maintenance mode with ./occ maintenance:mode --on and stopped the postgres database.
  4. Ran a full database dump with pg_dumpall -f database-v17.sql as the postgres user.
  5. Did a full system upgrade, which updated among other things the version of php and major version of postgres.
  6. Rebooted.
  7. Move the old /var/lib/postgres/data folder out of the way and created a new database for PostgreSQL v18 using initdb -D /var/lib/postgres/data --locale=C.UTF-8 --encoding=UTF-8 --data-checksums as the postgres user.
  8. Restored the database with psql -f database-v17.sql as the postgres user. There were some complaints about duplicated indexes being ignored while doing this.
  9. Turned off maintenance mode with ./occ maintenance:mode --off as the http user.

Log entries

Nextcloud

Please provide the log entries from your Nextcloud log that are generated during the time of problem (via the Copy raw option from Administration settings->Logging screen or from your nextcloud.log located in your data directory). Feel free to use a pastebin/gist service if necessary.

There are 3.5 MB of logs from the period of when the update was happening. You need to be more specific than this.

Web Browser

If the problem is related to the Web interface, open your browser inspector Console and Network tabs while refreshing (reloading) and reproducing the problem. Provide any relevant output/errors here that appear.

Issue is not related to web browser.

Web server / Reverse Proxy

The output of your Apache/nginx/system log in /var/log/____:

There are 1 MB of logs from the period. You need to be more specific than this.

Configuration

Nextcloud

The output of occ config:list system or similar is best, but, if not possible, the contents of your config.php file from /path/to/nextcloud is fine (make sure to remove any identifiable information!):

{
    "system": {
        "appstoreenabled": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "cloud.example.com"
        ],
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "default_phone_region": "NO",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "pgsql",
        "version": "33.0.3.2",
        "overwritehost": "cloud.example.com",
        "overwriteprotocol": "https",
        "overwritewebroot": "\/",
        "overwrite.cli.url": "https:\/\/cloud.example.com\/",
        "htaccess.RewriteBase": "\/",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "installed": true,
        "maintenance": false,
        "maintenance_window_start": 2,
        "theme": "",
        "loglevel": 2,
        "updater.release.channel": "stable",
        "mail_smtpmode": "smtp",
        "mail_smtpsecure": "ssl",
        "mail_sendmailmode": "smtp",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauthtype": "PLAIN",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "app_install_overwrite": []
    }
}

Apps

The output of occ app:list (if possible).

Enabled:
  - activity: 6.0.0
  - app_api: 33.0.0
  - bruteforcesettings: 6.0.0
  - calendar: 6.4.0
  - camerarawpreviews: 0.9.0
  - circles: 33.0.0
  - cloud_federation_api: 1.17.0
  - comments: 1.23.0
  - contacts: 8.4.5
  - contactsinteraction: 1.14.1
  - dashboard: 7.13.0
  - dav: 1.36.0
  - federatedfilesharing: 1.23.0
  - federation: 1.23.0
  - files: 2.5.0
  - files_downloadlimit: 5.1.0
  - files_pdfviewer: 6.0.0
  - files_reminders: 1.6.0
  - files_sharing: 1.25.2
  - files_trashbin: 1.23.0
  - files_versions: 1.26.0
  - firstrunwizard: 6.0.0
  - logreader: 6.0.0
  - lookup_server_connector: 1.21.0
  - nextcloud_announcements: 5.0.0
  - notifications: 6.0.0
  - oauth2: 1.21.0
  - password_policy: 5.0.0
  - photos: 6.0.0
  - privacy: 5.0.0
  - profile: 1.2.0
  - provisioning_api: 1.23.0
  - recommendations: 6.0.0
  - related_resources: 4.0.0
  - serverinfo: 5.0.0
  - settings: 1.16.0
  - sharebymail: 1.23.0
  - spreed: 23.0.4
  - support: 5.0.0
  - survey_client: 5.0.0
  - systemtags: 1.23.0
  - text: 7.0.1
  - theming: 2.8.0
  - twofactor_backupcodes: 1.22.0
  - twofactor_totp: 15.0.0
  - updatenotification: 1.23.0
  - user_status: 1.13.0
  - viewer: 6.0.0
  - weather_status: 1.13.0
  - webhook_listeners: 1.5.0
  - workflowengine: 2.15.0
Disabled:
  - admin_audit: 1.23.0
  - encryption: 2.21.0
  - files_external: 1.25.1 (installed 1.10.0)
  - suspicious_login: 11.0.0
  - testing: 1.23.0
  - twofactor_nextcloud_notification: 7.0.0
  - user_ldap: 1.24.0

I dug a bit into this and if I look at my database-v17.sql file I find entries like this in it, though they appear in a random order (I sorted them here for display purposes):

COPY public.oc_filecache (fileid, storage, path, path_hash, parent, name, mimetype, mimepart, size, mtime, storage_mtime, encrypted, unencrypted_size, etag, permissions, checksum) FROM stdin;
1       1               d41d8cd98f00b204e9800998ecf8427e        -1              2       1       54753886915     1778910011      1661464681      0       0       6a08033c3e7e5   23
2       1       files   45b963397aa40d4a0063e0d85e4fe7a1        1       files   2       1       47837874205     1778910011      1778172863      0       0       6a08033c3e7e5   31
16516   1       files/Drager    a0eb44a4681191abece0783f19eddbbb        2       Drager  2       1       1253627338      1778910011      1774196971      0       0       6a08033c3e7e5   31
16522   1       files/Drager/Hornwitser 0dc80dfc544d2f45050f9ebd322be579        16516   Hornwitser      2       1       49702107        1601487182      1601487176      0       0       5f74c14f644fa   31
16580   1       files/Drager/Hornwitser/model   9eb9beec1809effbf15945261e1a7b4a        16522   model   2       1       30924824        1601487157      1601487157      0       0       5f74c1362f0cb   31
16595   1       files/Drager/Hornwitser/model/paper-flight.blend        7bea986a4f885ec72e9e9780d153e04d        16580   paper-flight.blend      24      5       2745356 1374860012      1374860012      0       0       d935ac07333f1fa918d6f4f73bfb2ead        27

But if I try to query for them in the database they don’t exist.

nextcloud=# SELECT * FROM oc_filecache WHERE fileid in (1, 2, 16516, 16522, 16580, 16595);
 fileid | storage | path |            path_hash             | parent | name | mimetype | mimepart |    size     |   mtime    | storage_mtime | encrypted | unencrypted_size |     etag      | permissions | checksum
--------+---------+------+----------------------------------+--------+------+----------+----------+-------------+------------+---------------+-----------+------------------+---------------+-------------+----------
      1 |       1 |      | d41d8cd98f00b204e9800998ecf8427e |     -1 |      |        2 |        1 | 12939674683 | 1779063953 |    1661464681 |         0 |                0 | 6a0a5c913861f |          23 |
      1 |       1 |      | d41d8cd98f00b204e9800998ecf8427e |     -1 |      |        2 |        1 | 12939674683 | 1779063953 |    1661464681 |         0 |                0 | 6a0a5c913861f |          23 |

Looking into nextcloud.log I find entries like this

{
        "reqId": "3mibpH4SB8UDez0v9cGU",
        "level": 0,
        "time": "2026-05-17T21:59:48+00:00",
        "remoteAddr": "",
        "user": "--",
        "app": "no app in context",
        "method": "",
        "url": "/occ",
        "scriptName": "/occ",
        "message": "dirty table reads: SELECT `filecache`.`fileid`, `storage`, `path`, `path_hash`, `filecache`.`parent`, `filecache`.`name`, `mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`, `encrypted`, `filecache`.`etag`, `filecache`.`permissions`, `checksum`, `unencrypted_size`, `metadata_etag`, `creation_time`, `upload_time`, `meta`.`json` AS `meta_json`, `meta`.`sync_token` AS `meta_sync_token` FROM `*PREFIX*filecache` `filecache` LEFT JOIN `*PREFIX*filecache_extended` `fe` ON `filecache`.`fileid` = `fe`.`fileid` LEFT JOIN `*PREFIX*files_metadata` `meta` ON `filecache`.`fileid` = `meta`.`file_id` WHERE (`path_hash` = :dcValue1) AND (`storage` = :dcValue2)",
        "userAgent": "--",
        "version": "32.0.9.2",
        "occ_command": [
                "/srv/http/cloud/updater/../occ",
                "upgrade"
        ],
        "exception": {
                "Exception": "Exception",
                "Message": "dirty table reads: SELECT `filecache`.`fileid`, `storage`, `path`, `path_hash`, `filecache`.`parent`, `filecache`.`name`, `mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`, `encrypted`, `filecache`.`etag`, `filecache`.`permissions`, `checksum`, `unencrypted_size`, `metadata_etag`, `creation_time`, `upload_time`, `meta`.`json` AS `meta_json`, `meta`.`sync_token` AS `meta_sync_token` FROM `*PREFIX*filecache` `filecache` LEFT JOIN `*PREFIX*filecache_extended` `fe` ON `filecache`.`fileid` = `fe`.`fileid` LEFT JOIN `*PREFIX*files_metadata` `meta` ON `filecache`.`fileid` = `meta`.`file_id` WHERE (`path_hash` = :dcValue1) AND (`storage` = :dcValue2)",
                "Code": 0,
                "Trace": [
                        {
                                "file": "/srv/http/cloud/lib/private/DB/ConnectionAdapter.php",
                                "line": 50,
                                "function": "executeQuery",
                                "class": "OC\\DB\\Connection",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/lib/private/DB/QueryBuilder/QueryBuilder.php",
                                "line": 268,
                                "function": "executeQuery",
                                "class": "OC\\DB\\ConnectionAdapter",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/lib/private/DB/QueryBuilder/ExtendedQueryBuilder.php",
                                "line": 270,
                                "function": "executeQuery",
                                "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/lib/private/Files/Cache/Cache.php",
                                "line": 133,
                                "function": "executeQuery",
                                "class": "OC\\DB\\QueryBuilder\\ExtendedQueryBuilder",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/lib/private/Files/View.php",
                                "line": 1373,
                                "function": "get",
                                "class": "OC\\Files\\Cache\\Cache",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/lib/private/Files/View.php",
                                "line": 1420,
                                "function": "getCacheEntry",
                                "class": "OC\\Files\\View",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/lib/private/Files/Node/Root.php",
                                "line": 169,
                                "function": "getFileInfo",
                                "class": "OC\\Files\\View",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/lib/private/Files/Node/Folder.php",
                                "line": 112,
                                "function": "get",
                                "class": "OC\\Files\\Node\\Root",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/lib/private/Files/SimpleFS/SimpleFolder.php",
                                "line": 57,
                                "function": "get",
                                "class": "OC\\Files\\Node\\Folder",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/lib/private/App/AppStore/Fetcher/Fetcher.php",
                                "line": 140,
                                "function": "getFile",
                                "class": "OC\\Files\\SimpleFS\\SimpleFolder",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/lib/private/App/AppStore/Fetcher/AppFetcher.php",
                                "line": 157,
                                "function": "get",
                                "class": "OC\\App\\AppStore\\Fetcher\\Fetcher",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/lib/private/Installer.php",
                                "line": 168,
                                "function": "get",
                                "class": "OC\\App\\AppStore\\Fetcher\\AppFetcher",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/lib/private/Installer.php",
                                "line": 104,
                                "function": "downloadApp",
                                "class": "OC\\Installer",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/lib/private/Updater.php",
                                "line": 382,
                                "function": "updateAppstoreApp",
                                "class": "OC\\Installer",
                                "type": "->",
                                "args": [
                                        "*** sensitive parameters replaced ***"
                                ]
                        },
                        {
                                "file": "/srv/http/cloud/lib/private/Updater.php",
                                "line": 247,
                                "function": "upgradeAppStoreApps",
                                "class": "OC\\Updater",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/lib/private/Updater.php",
                                "line": 101,
                                "function": "doUpgrade",
                                "class": "OC\\Updater",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/core/Command/Upgrade.php",
                                "line": 193,
                                "function": "upgrade",
                                "class": "OC\\Updater",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/3rdparty/symfony/console/Command/Command.php",
                                "line": 326,
                                "function": "execute",
                                "class": "OC\\Core\\Command\\Upgrade",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/3rdparty/symfony/console/Application.php",
                                "line": 1083,
                                "function": "run",
                                "class": "Symfony\\Component\\Console\\Command\\Command",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/3rdparty/symfony/console/Application.php",
                                "line": 324,
                                "function": "doRunCommand",
                                "class": "Symfony\\Component\\Console\\Application",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/3rdparty/symfony/console/Application.php",
                                "line": 175,
                                "function": "doRun",
                                "class": "Symfony\\Component\\Console\\Application",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/lib/private/Console/Application.php",
                                "line": 187,
                                "function": "run",
                                "class": "Symfony\\Component\\Console\\Application",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/console.php",
                                "line": 92,
                                "function": "run",
                                "class": "OC\\Console\\Application",
                                "type": "->"
                        },
                        {
                                "file": "/srv/http/cloud/occ",
                                "line": 33,
                                "args": [
                                        "/srv/http/cloud/console.php"
                                ],
                                "function": "require_once"
                        }
                ],
                "File": "/srv/http/cloud/lib/private/DB/Connection.php",
                "Line": 407,
                "message": "dirty table reads: SELECT `filecache`.`fileid`, `storage`, `path`, `path_hash`, `filecache`.`parent`, `filecache`.`name`, `mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`, `encrypted`, `filecache`.`etag`, `filecache`.`permissions`, `checksum`, `unencrypted_size`, `metadata_etag`, `creation_time`, `upload_time`, `meta`.`json` AS `meta_json`, `meta`.`sync_token` AS `meta_sync_token` FROM `*PREFIX*filecache` `filecache` LEFT JOIN `*PREFIX*filecache_extended` `fe` ON `filecache`.`fileid` = `fe`.`fileid` LEFT JOIN `*PREFIX*files_metadata` `meta` ON `filecache`.`fileid` = `meta`.`file_id` WHERE (`path_hash` = :dcValue1) AND (`storage` = :dcValue2)",
                "tables": "[\"oc_migrations\",\"oc_share\",\"oc_jobs\",\"oc_appconfig\",\"oc_preferences\",\"oc_calendars\",\"oc_activity\",\"oc_text_steps\",\"oc_text_sessions\",\"oc_text_documents\",\"oc_filecache\"]",
                "reads": "[\"oc_filecache\",\"oc_filecache_extended\",\"oc_files_metadata\"]",
                "exception": "{\"class\":\"Exception\",\"message\":\"dirty table reads: SELECT `filecache`.`fileid`, `storage`, `path`, `path_hash`, `filecache`.`parent`, `filecache`.`name`, `mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`, `encrypted`, `filecache`.`etag`, `filecache`.`permissions`, `checksum`, `unencrypted_size`, `metadata_etag`, `creation_time`, `upload_time`, `meta`.`json` AS `meta_json`, `meta`.`sync_token` AS `meta_sync_token` FROM `*PREFIX*filecache` `filecache` LEFT JOIN `*PREFIX*filecache_extended` `fe` ON `filecache`.`fileid` = `fe`.`fileid` LEFT JOIN `*PREFIX*files_metadata` `meta` ON `filecache`.`fileid` = `meta`.`file_id` WHERE (`path_hash` = :dcValue1) AND (`storage` = :dcValue2)\",\"code\":0,\"file\":\"/srv/http/cloud/lib/private/DB/Connection.php:407\",\"trace\":\"#0 /srv/http/cloud/lib/private/DB/ConnectionAdapter.php(50): OC\\DB\\Connection->executeQuery()\\n#1 /srv/http/cloud/lib/private/DB/QueryBuilder/QueryBuilder.php(268): OC\\DB\\ConnectionAdapter->executeQuery()\\n#2 /srv/http/cloud/lib/private/DB/QueryBuilder/ExtendedQueryBuilder.php(270): OC\\DB\\QueryBuilder\\QueryBuilder->executeQuery()\\n#3 /srv/http/cloud/lib/private/Files/Cache/Cache.php(133): OC\\DB\\QueryBuilder\\ExtendedQueryBuilder->executeQuery()\\n#4 /srv/http/cloud/lib/private/Files/View.php(1373): OC\\Files\\Cache\\Cache->get()\\n#5 /srv/http/cloud/lib/private/Files/View.php(1420): OC\\Files\\View->getCacheEntry()\\n#6 /srv/http/cloud/lib/private/Files/Node/Root.php(169): OC\\Files\\View->getFileInfo()\\n#7 /srv/http/cloud/lib/private/Files/Node/Folder.php(112): OC\\Files\\Node\\Root->get()\\n#8 /srv/http/cloud/lib/private/Files/SimpleFS/SimpleFolder.php(57): OC\\Files\\Node\\Folder->get()\\n#9 /srv/http/cloud/lib/private/App/AppStore/Fetcher/Fetcher.php(140): OC\\Files\\SimpleFS\\SimpleFolder->getFile()\\n#10 /srv/http/cloud/lib/private/App/AppStore/Fetcher/AppFetcher.php(157): OC\\App\\AppStore\\Fetcher\\Fetcher->get()\\n#11 /srv/http/cloud/lib/private/Installer.php(168): OC\\App\\AppStore\\Fetcher\\AppFetcher->get()\\n#12 /srv/http/cloud/lib/private/Installer.php(104): OC\\Installer->downloadApp()\\n#13 /srv/http/cloud/lib/private/Updater.php(382): OC\\Installer->updateAppstoreApp()\\n#14 /srv/http/cloud/lib/private/Updater.php(247): OC\\Updater->upgradeAppStoreApps()\\n#15 /srv/http/cloud/lib/private/Updater.php(101): OC\\Updater->doUpgrade()\\n#16 /srv/http/cloud/core/Command/Upgrade.php(193): OC\\Updater->upgrade()\\n#17 /srv/http/cloud/3rdparty/symfony/console/Command/Command.php(326): OC\\Core\\Command\\Upgrade->execute()\\n#18 /srv/http/cloud/3rdparty/symfony/console/Application.php(1083): Symfony\\Component\\Console\\Command\\Command->run()\\n#19 /srv/http/cloud/3rdparty/symfony/console/Application.php(324): Symfony\\Component\\Console\\Application->doRunCommand()\\n#20 /srv/http/cloud/3rdparty/symfony/console/Application.php(175): Symfony\\Component\\Console\\Application->doRun()\\n#21 /srv/http/cloud/lib/private/Console/Application.php(187): Symfony\\Component\\Console\\Application->run()\\n#22 /srv/http/cloud/console.php(92): OC\\Console\\Application->run()\\n#23 /srv/http/cloud/occ(33): require_once('...')\\n#24 {main}\"}",
                "CustomMessage": "dirty table reads: SELECT `filecache`.`fileid`, `storage`, `path`, `path_hash`, `filecache`.`parent`, `filecache`.`name`, `mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`, `encrypted`, `filecache`.`etag`, `filecache`.`permissions`, `checksum`, `unencrypted_size`, `metadata_etag`, `creation_time`, `upload_time`, `meta`.`json` AS `meta_json`, `meta`.`sync_token` AS `meta_sync_token` FROM `*PREFIX*filecache` `filecache` LEFT JOIN `*PREFIX*filecache_extended` `fe` ON `filecache`.`fileid` = `fe`.`fileid` LEFT JOIN `*PREFIX*files_metadata` `meta` ON `filecache`.`fileid` = `meta`.`file_id` WHERE (`path_hash` = :dcValue1) AND (`storage` = :dcValue2)"
        }
}

Looks like I’ve managed to corrupt the database by having multiple things write to it at the same time. It’s possible that I hand’t properly prevented database access while restoring from the sql dump, and that nextcloud mangled it as a result.

I will try restoring the database again from the dump and see if that works.

Edit: The nextcloud.log line is from before I moved the database to the new version, so that looks like red herring. There’s nothing in the nextcloud.log file from after I installed postgres v18 and restored the database from the dump.

In general I would recommend not to perform Nextcloud upgrade in parallel with DB upgrade.. I would better upgrade only the application, test everything and perform DB upgrade later.

To recover from the issue I would stop everything and try to restore the DB.. (maybe use PG17 and your old data dir) ..check contents of the oc_filecache before you continue..

TL;DR I somehow corrupted the filecache database while migrating from postgresql v17 to v18 and that is what caused the files to go missing. They were still in the data folder on the server. After redoing the migration from the v17 dump my files are back.


In general I would recommend not to perform Nextcloud upgrade in parallel with DB upgrade

It was working after doing the Nextcloud upgrade, I didn’t check thoroughly before starting the DB upgrade which is why I included it in the description. Should have probably looked through it better before carrying on with the DB and system upgrade.


I figured out a fix for the problem. I recreated the database from the v17 dump on posgresql v18, but this time I changed the password in config.php to make sure nextcloud could not access the DB while doing this. Now I’m able to query the expected files from the database.

nextcloud=# SELECT * FROM oc_filecache WHERE fileid in (1, 2, 16516, 16522, 16580, 16595);
 fileid | storage |                       path                       |            path_hash             | parent |        name        | mimetype | mimepart |    size     |   mtime    | storage_mtime | encrypted | unencrypted_size |               etag               | permissions | checksum
--------+---------+--------------------------------------------------+----------------------------------+--------+--------------------+----------+----------+-------------+------------+---------------+-----------+------------------+----------------------------------+-------------+----------
      1 |       1 |                                                  | d41d8cd98f00b204e9800998ecf8427e |     -1 |                    |        2 |        1 | 54753886915 | 1778910011 |    1661464681 |         0 |                0 | 6a08033c3e7e5                    |          23 |
      2 |       1 | files                                            | 45b963397aa40d4a0063e0d85e4fe7a1 |      1 | files              |        2 |        1 | 47837874205 | 1778910011 |    1778172863 |         0 |                0 | 6a08033c3e7e5                    |          31 |
  16516 |       1 | files/Drager                                     | a0eb44a4681191abece0783f19eddbbb |      2 | Drager             |        2 |        1 |  1253627338 | 1778910011 |    1774196971 |         0 |                0 | 6a08033c3e7e5                    |          31 |
  16522 |       1 | files/Drager/Hornwitser                          | 0dc80dfc544d2f45050f9ebd322be579 |  16516 | Hornwitser         |        2 |        1 |    49702107 | 1601487182 |    1601487176 |         0 |                0 | 5f74c14f644fa                    |          31 |
  16580 |       1 | files/Drager/Hornwitser/model                    | 9eb9beec1809effbf15945261e1a7b4a |  16522 | model              |        2 |        1 |    30924824 | 1601487157 |    1601487157 |         0 |                0 | 5f74c1362f0cb                    |          31 |
  16595 |       1 | files/Drager/Hornwitser/model/paper-flight.blend | 7bea986a4f885ec72e9e9780d153e04d |  16580 | paper-flight.blend |       24 |        5 |     2745356 | 1374860012 |    1374860012 |         0 |                0 | d935ac07333f1fa918d6f4f73bfb2ead |          27 |

Since I had no idea about the condition of the filecache and I had synced files to the nextcloud after the db got corrupt, wiped and restored, I ran /occ files:scan --all as the http user. It printed this result when it was done.

+---------+--------+-----+---------+---------+--------+--------------+
| Folders | Files  | New | Updated | Removed | Errors | Elapsed time |
+---------+--------+-----+---------+---------+--------+--------------+
| 18185   | 115779 | 0   | 6230    | 67      | 0      | 04:29:13     |
+---------+--------+-----+---------+---------+--------+--------------+

I also ran /occ files:scan-app-data.

After doing this the files were back in the web interface, and after letting the desktop client do its sync thing my files are also back on my desktop.

I’ll leave this here as a cautionary tale. Make very sure Nextcloud can’t access the database when doing a database migration!