How to find missing files?

Hello,

I was asked to operate an existing Nextcloud instance.

the formder admin was moving the instance from an old server to an new one. The old server is still online, and the new one is in use for several month now.

It now turned out that some files has not been copied from the old data folder to the new one. So I need to find out:
Which files listed in the database do not exist in the file system?

How can I do it?
It makes no sense to run an occ files:scan --all because then all missing files would also be deleted from the database and are gone forever.

Any ideas? System is Nexcloud 31 running on Debian 12.

If I were you, I would use standard Linux mechanisms. For example, you can use find . -type f to display all files on both systems. You can then try to compare the two outputs. For example, you can use a script to go through the first file list with the old data and see if the file is included in the second file list.

Hi, the thing is that on this instance we are talking about ~1.000.000 files. Is there any way to from the database an output like
/data/username/files/file1.txt
/data/username/files/file2.txt

The I can use this list to create script which is checking every line and is reporting when the files does not exist.

Since the new instancce is online for month I will definitively have a change between two filelists made from the OS.

Yes but you must only compare in /path/to/nextcloud/data . You also only need to search in one direction. You go through the list of the first file and search for the entries in the second file. You can also exclude some parts of the directory structure in advance, such appdata_ (thumbnails, …), updater-, etc. Maybe also exclude files_trashbin and files_versions. You can grep -v them all after a full find. Then search the new list in the second full file.

in this old topic I made some efforts to reverse engineer the structure of the oc_filecache database table. With little effort you could create a list of files in the database and their (expected) path in the filesystem. it’s easy then to check which files are missing. this one is talking about the opposite direction - remove all files records not on disk anymore.. might be helpful as well

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.