How to rescan filesystem in owncloud 5

In this post we will know how to rescan file system in Owncloud 5.x version.While working in owncloud I got the application called rescan but it was not working and I got a blank page.After exploring more into owncloud I got two ways to rescan the file system.

Owncloud Version: 5.0.22

Method 1: Using console.php file to rescan the owncloud filesystem.

Syntax:
For User:

/path/of/owncloud/console.php files:scan Userid

For full scan:

/path/of/owncloud/console.php files:scan --all

For eg. Here I have my these details. Hence the change the below given values as per your details

Owncloud installed path: /var/www/owncloud
Userid: sharad

/var/www/owncloud/console.php files:scan sharad

For full scan

/var/www/owncloud/console.php files:scan --all

Method 2: This method requires mysql server username and password. Here we will truncate the table which store the filesystem information.

The details of my mysql server
Note: Replace the value as per your information in given below fields.

Database Name: owncloud
Table Name: oc_filecache

Step 1: Login into mysql server

mysql -u root -p

Step 2: After login into mysql server you will mysql prompt (mysql >)

Change to owncloud database. Here for my owncloud server,I am using the database name owncloud.

mysql > use owncloud;

Step 3: Now truncate the table oc_filecache

truncate oc_filecache;

Clear filecache from database of particular user,follow the given below steps

Here, we are clearing filecache for user called sharad. First we will get its storage id then clear its rows from oc_filecache table

UserID = sharad

Step 1:

Note: Numeric_id for user called sharad is 2 and it is stoarge id which we will use it to delete its rows from oc_filecache.Hence check your table first and replace the 2 numeric_id value which you got from given below command

mysql> select * from oc_storages;
+---------------------------------------+------------+
| id                                    | numeric_id |
+---------------------------------------+------------+
| local::/var/lib/owncloud/data/admin/  |          1 |
| local::/var/lib/owncloud/data/sharad/ |          2 |
+---------------------------------------+------------+
2 rows in set (0.00 sec)

mysql> select  * from oc_filecache where storage = 2;
+--------+---------+-------------------+----------------------------------+--------+-------------+----------+----------+-------+------------+-----------+------------------+---------------+
| fileid | storage | path              | path_hash                        | parent | name        | mimetype | mimepart | size  | mtime      | encrypted | unencrypted_size | etag          |
+--------+---------+-------------------+----------------------------------+--------+-------------+----------+----------+-------+------------+-----------+------------------+---------------+
|      4 |       2 |                   | d41d8cd98f00b204e9800998ecf8427e |     -1 |             |        2 |        1 | 95102 | 1384442192 |         0 |                0 | 5284e95230eb2 |
|      5 |       2 | files             | 45b963397aa40d4a0063e0d85e4fe7a1 |      4 | files       |        2 |        1 | 95102 | 1384442218 |         0 |                0 | 5284e96a7b19c |
|      6 |       2 | files/mysql.png   | f876c595495bf53c3eefa2cca290ed53 |      5 | mysql.png   |        4 |        3 | 35405 | 1384442217 |         0 |                0 | 5284e969ab72e |
|      7 |       2 | files/mysql2.png  | 098fd1ef4694f1a9708fcac12c095192 |      5 | mysql2.png  |        4 |        3 | 58305 | 1384442218 |         0 |                0 | 5284e96a4006e |
|      8 |       2 | files/htaccess[1] | 30ba77b8d85dfe0b16c1f8fc70255225 |      5 | htaccess[1] |        6 |        5 |  1392 | 1384442218 |         0 |                0 | 5284e96ab674d |
+--------+---------+-------------------+----------------------------------+--------+-------------+----------+----------+-------+------------+-----------+------------------+---------------+
5 rows in set (0.00 sec)

mysql> delete from oc_filecache where storage = 2;
Query OK, 5 rows affected (0.08 sec)

mysql>

9 thoughts on “How to rescan filesystem in owncloud 5”

    • Hello Andre,

      Thanks for appreciating this post.
      I opened the owncloud forum link but it shown me the message “Topic not found”.
      Give me the “Question asked” with author name .I will look into the owncloud forum
      (My id in owncloud forum is sharadchhetri)

      I wrote this post the problem I faced on owncloud 5.x version.
      For solving scanning problem in my 1.2 TB Owncloud Data.It had taken time.

      Kindly let me know,what exactly is the issue.And how you are finding ,the scan is not done properly.
      (Note: If you are searching file name in Search box,it uses lucene. For lucene problem,troubleshooting is different.
      The lucene solution I have posted in this article.
      )

      Reply
    • OK,now I can see your question.
      The owncloud version is 6.x installed in Windows Server with IIS web server.

      Login into the database server and show me the output from table.

      follow the method 2

      Get user id from oc_storage table
      select * from oc_storages;

      Now , check the listed files/directory and path in oc_filecache table.

      replace user-id word and give numeric user id
      select * from oc_filecache where storage = user-id

      I just want to see , do this table have information related to this user.

      (Once clear the web browser cache also)

      Reply
  1. Hi,

    I’ve the same problem. Web interface shows several folders twice. I cannot store some (just some) folders, they are deleted in few seconds.
    Browsing some folders leads to recursive jump to root.
    I tried to disable deleted files and versions. Still no success. Rescan works ok, but with no effect …Any idea, please?

    Jaroslav

    Reply
    • Hello Jaroslav,

      owncloud/data directory in Server has the actual Data. The owncloud/dir directory has subdirectory with the username. If you explore these subdirectory you will find the data inside these directory.

      First take the mysql database backup

      Then apply method 2 – truncate oc_filecache
      Then apply Method 1 – console.php scan

      I did not get which you have written “Browsing some folders leads to recursive jump to root.”.
      Is this happening when you are log in server with command line and using cd command to go into directories ?

      Reply
    • Hello Irfan,

      Thanks for appreciation.
      I have not tested the active directory with owncloud still so far.
      Can you scan the data directory with below given two commands
      console.php is found at /var/www/html/owncloud [Replace with owncloud web directory path as per your Server info]

      (1) php console.php files:scan [user_id directory,Owncloud creates a data directory of user_id with its same name, you can see at ls -ld /var/www/html/owncloud/data/* ]

      (2) php console.php files:scan –all [It rescan all users filesystem means their data directory]

      These two command will not give any problem,it is safe 🙂
      Suggest you to try with 1st command,if it is able to scan the data directory of user_id . If successful then go for second command for all users

      Try once, and let me know the feedback.

      Reply
  2. Hi Sharad,

    thanks for this article. The first method solved incorrect folder size on the webinterface.

    Now I just need to correct to correct the quota….which displays 2 GB (while having actually used > 30 GB.

    Best regards

    Martin

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.