Trigger files scan without occ web app in TrueNAS Scale container? (Can't write to External Storage)

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

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:

Nextcloud version (eg, 20.0.5): 29
Operating system and version (eg, Ubuntu 20.04): TrueNAS-SCALE-23.10.1.1
Apache or nginx version (eg, Apache 2.4.25): don’t know where to find
PHP version (eg, 7.4): don’t know where to find

The issue you are facing:

Is this the first time you’ve seen this error? (Y/N): N

Steps to replicate it:

  1. When i go to NextCloud web / phone app and login, it shows nothing under Files
  2. Can see some of the content when i click on Photos or go into the SMB share, i see some data. The create folder option is grayed out too

The output of your Nextcloud log in Admin > Logging: (this is part of the log, browser crashes if I try to paste entire log file (incl. pastebin)

"reqId":"Q4uH9vZddmBQB2L2Hnnh","level":3,"time":"2024-03-19T03:25:58+00:00","remoteAddr":"192.168.41.123","user":"admin","app":"index","method":"GET","url":"/core/preview?c=1ea09708119834b5e13388ae0e22a429&fileId=47&x=256&y=256","message":"Could not get appdata folder for preview","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0","version":"28.0.3.2","exception":{"Exception":"RuntimeException","Message":"Could not get appdata folder for preview","Code":0,"Trace":[{"file":"/var/www/html/lib/private/Files/AppData/AppData.php","line":147,"function":"getAppDataFolder","class":"OC\\Files\\AppData\\AppData","type":"->","args":[]},{"file":"/var/www/html/lib/private/Preview/Storage/Root.php","line":74,"function":"newFolder","class":"OC\\Files\\AppData\\AppData","type":"->","args":["6/7/c/6/a/1/e/47"]},{"file":"/var/www/html/lib/private/Preview/Generator.php","line":607,"function":"newFolder","class":"OC\\Preview\\Storage\\Root","type":"->","args":["47"]},{"file":"/var/www/html/lib/private/Preview/Generator.php","line":133,"function":"getPreviewFolder","class":"OC\\Preview\\Generator","type":"->","args":[["OC\\Files\\Node\\File"]]},{"file":"/var/www/html/lib/private/Preview/Generator.php","line":110,"function":"generatePreviews","class":"OC\\Preview\\Generator","type":"->","args":[["OC\\Files\\Node\\File"],[[256,256,true,"fill"]],"image/jpeg"]},{"file":"/var/www/html/lib/private/PreviewManager.php","line":187,"function":"getPreview","class":"OC\\Preview\\Generator","type":"->","args":[["OC\\Files\\Node\\File"],256,256,true,"fill",null]},{"file":"/var/www/html/core/Controller/PreviewController.php","line":173,"function":"getPreview","class":"OC\\PreviewManager","type":"->","args":[["OC\\Files\\Node\\File"],256,256,true,"fill"]},{"file":"/var/www/html/core/Controller/PreviewController.php","line":141,"function":"fetchPreview","class":"OC\\Core\\Controller\\PreviewController","type":"->","args":[["OC\\Files\\Node\\File"],256,256,false,true,"fill",false]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":230,"function":"getPreviewByFileId","class":"OC\\Core\\Controller\\PreviewController","type":"->","args":[47,256,256,false,true,"fill",false]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":137,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[["OC\\Core\\Controller\\PreviewController"],"getPreviewByFileId"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":184,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[["OC\\Core\\Controller\\PreviewController"],"getPreviewByFileId"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":315,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OC\\Core\\Controller\\PreviewController","getPreviewByFileId",["OC\\AppFramework\\DependencyInjection\\DIContainer"],["core.Preview.getPreviewByFileId"]]},{"file":"/var/www/html/lib/base.php","line":1069,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/core/preview"]},{"file":"/var/www/html/index.php","line":39,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/lib/private/Files/AppData/AppData.php","Line":108,"message":"Could not get appdata folder for preview","exception":{},"CustomMessage":"Could not get appdata folder for preview"}}
{"reqId":"6EcwdPPBBSvRRPIH28i0","level":3,"time":"2024-03-19T03:36:10+00:00","remoteAddr":"::1","user":"admin","app":"files_external","method":"POST","url":"/apps/files_external/globalstorages","message":"Local storage path does not exist \"photos/\"","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0","version":"28.0.3.2","exception":{"Exception":"OCP\\Files\\StorageNotAvailableException","Message":"Local storage path does not exist \"photos/\"","Code":1,"Trace":[{"file":"/var/www/html/apps/files_external/lib/MountConfig.php","line":128,"function":"__construct","class":"OC\\Files\\Storage\\Local","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/apps/files_external/lib/Controller/StoragesController.php","line":245,"function":"getBackendStatus","class":"OCA\\Files_External\\MountConfig","type":"::","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/apps/files_external/lib/Controller/GlobalStoragesController.php","line":134,"function":"updateStorageStatus","class":"OCA\\Files_External\\Controller\\StoragesController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":230,"function":"create","class":"OCA\\Files_External\\Controller\\GlobalStoragesController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":137,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[["OCA\\Files_External\\Controller\\GlobalStoragesController"],"create"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":184,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[["OCA\\Files_External\\Controller\\GlobalStoragesController"],"create"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":315,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Files_External\\Controller\\GlobalStoragesController","create",["OC\\AppFramework\\DependencyInjection\\DIContainer"],["files_external.global_storages.create"]]},{"file":"/var/www/html/lib/base.php","line":1069,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/files_external/globalstorages"]},{"file":"/var/www/html/index.php","line":39,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/lib/private/Files/Storage/Local.php","Line":106,"Hint":"Storage is temporarily not available","message":"Local storage path does not exist \"photos/\"","exception":{},"CustomMessage":"Local storage path does not exist \"photos/\""}}
{"reqId":"U785cNacW5GJWXNlHoY7","level":3,"time":"2024-03-19T03:36:13+00:00","remoteAddr":"192.168.41.123","user":"admin","app":"files_external","method":"GET","url":"/apps/files_external/globalstorages/1?testOnly=true","message":"Local storage path does not exist \"photos/\"","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0","version":"28.0.3.2","exception":{"Exception":"OCP\\Files\\StorageNotAvailableException","Message":"Local storage path does not exist \"photos/\"","Code":1,"Trace":[{"file":"/var/www/html/apps/files_external/lib/MountConfig.php","line":128,"function":"__construct","class":"OC\\Files\\Storage\\Local","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/apps/files_external/lib/Controller/StoragesController.php","line":245,"function":"getBackendStatus","class":"OCA\\Files_External\\MountConfig","type":"::","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/apps/files_external/lib/Controller/StoragesController.php","line":298,"function":"updateStorageStatus","class":"OCA\\Files_External\\Controller\\StoragesController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":230,"function":"show","class":"OCA\\Files_External\\Controller\\StoragesController","type":"->","args":[1,"*** sensitive parameters replaced ***"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":137,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[["OCA\\Files_External\\Controller\\GlobalStoragesController"],"show"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":184,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[["OCA\\Files_External\\Controller

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

PASTE HERE

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

PASTE HERE

PASTE HERE


Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

![image|690x363](upload://qtCP85EZlZHCtgcMFuVlVDJ1rLh.png)

Hi,

To launch occ commands in your conatiner from Truenas ( i’m assuming you are using k3s directly from the webUI of Truenas ) :

In WebUI go to apps, select nextcloud and in the right colonn click the console icon :

Then make sure to select the nextcloud pod :

Once you are in console :

su
then
su -m www-data -c 'php occ files:scan --all'

And you are good to go.

1 Like

Hi, this might be a very dumb question but HOW do i get the “su” password?

Read the manpage: su(1) - Linux manual page

In Unix-like operating systems, su (short for “substitute user” or “switch user”) and sudo (short for “superuser do”) are similar in that they both allow users to run commands with the privileges of another user, typically the superuser (root).

su:

  • When you use su, you switch to another user account, and you need to know the password of the target account.
  • If you just type su without specifying a user, it defaults to the root account.
  • For example, to switch to the root account, you type su and then enter the root password.

sudo:

  • sudo allows a permitted user to execute a command as the superuser or another user, as specified in the sudoers file.
  • When using sudo, you typically enter your own password, not the password of the target user.
  • For example, sudo su allows you to switch to the root account, but you enter your own password.

Regarding your specific case, to use su to switch to the root user and then switch to the www-data user to run a command:

su
su -m www-data -c 'php occ files:scan --all'

Here’s what happens:

  1. su: This command switches to the root user. You will need to enter the root password at this point.
  2. su -m www-data -c 'php occ files:scan --all': After becoming root, this command switches to the www-data user and runs the specified command (php occ files:scan --all). You will not have to enter a password at this point, since you are root since step 1.

If you have sudo privileges, you might be able to achieve the same result without needing to know the root password. Here’s an equivalent using sudo:

sudo -u www-data php occ files:scan --all

In this case, you use sudo to run the command as the www-data user directly. You’ll need to enter your own password, provided you have the necessary sudo privileges to run commands as www-data.


Much and good luck,
ernolf

Hi ernolf,
thank you for the fast reply, i do have access to the root user on the host system (truenas) and i did try the same password inside the pod but with no luck, i’ve asked on the truenas forum’s in hope of getting to the bottom of this, in the mean while are there any other ways of importing a lot of data all at once in nextcloud? the windows sync app seems to crash, and using webDav with winSCP is very slow, are there any other methods ?

I am very sory. I have absolutely no TrueNAS knowledge.
Anyone who gets involved with TrueNAS should already be familiar with it. It is making difficult matter even more difficult by adding more layers.
It is a mystery to me why people voluntarily burden themselves with so many - in my eyes - nonsense layers. :wink:

As what user you are inside of the pod? What is the part of the prompt before the @ sign?

occ is crucial and the main commandline interface to nextcloud. So you will need to know how to get into your pod. There is no other way.

You should get inside of your pod as root user and make sure you are on the Nextcloud webroot directory and the run

sudo -u www-data php occ files:scan --all

(Assuming your webserver user running nextlcoud is www-data)


Much and good luck,
ernolf

I did find a “workaround” i never needed to get the “SU” access, i just needed to tun the OCC command

So i found this:

It’s an app that gives you access to the OCC console from the web UI, with this i was able to run:

files:scan

image

And the files are now avaible in nextcloud

So, this fixes the issue!

1 Like
  • The application is not a real interactive terminal and does not support long running tasks. So if your instance is pretty big, commands like occ files:scan will time out and fail.

I did read that, but i ran it any way and it did not time out:

image

And now i have all my files!

This is 225GB of files and it ran just fine