Bart Simons


A 1 post collection

Manually add files to ownCloud

 •  Filed under manually, add, files, folders, owncloud

Let's face it: you've got gigabytes of files to add to your ownCloud server. You can of course use the desktop client to sync all those files, but what if we were talking about almost a terabyte?

Add files manually to your ownCloud server

This is probably the quickest and less complicated way of adding files. There are many alternative ways to transfer your files to your ownCloud server:

  • FTP Upload;
  • SCP Upload;
  • Local disk to ownCloud disk transfer;
  • USB disk to ownCloud disk transfer.

It's just as simple as dragging a folder to another folder. The only problem is that you might not know yet where ownCloud files are stored. I made life a little bit easier with this nifty little Bash snippet that automatically finds your ownCloud data directory:

find / -name config.php 2>/dev/null | while read line ; do cat "$line" | grep " 'datadirectory'" ; done  

Your output should then look something like this:

ownCloud Data Directory Snippet

So according to the snippet of code my ownCloud data directory is located at /var/www/owncloud/data so let's cd into that directory to check out what's in there.

ownCloud Data Directory Contents

As you can see, we have multiple files in here. My ownCloud username is bart, so let's take a look in that folder.

ownCloud Data Directory Closer Look

Now this looks interesting. If I check my ownCloud web portal I can see that the directory structure is the same:

ownCloud Default Web Interface Folders

So I created a folder called TestFolder123 in the web interface and executed ls -la on the server's console.

ownCloud Default Web Interface With Test Folder

ownCloud Server Console Test Folder

So I tried to do the same thing, but vice versa. I created a folder on the console side, updated the folder's ownership and afterwards checked if the folder appeared in the web interface, with some surprising results:

ownCloud Server Console Test Folder 2

ownCloud Default Web Interface Without Console Test Folder

What the heck?!
Where did my folder go??!
Okay.. let me explain what's going on here. The ownCloud system basically expects two things from a file/folder in order to be indexed as a file:

  • The file/folder needs to be physically available;
  • The file/folder needs to exist in the ownCloud database.

Moving a file/folder into ownCloud's data directory doesn't add it to the database automatically. Luckily, the ownCloud developers were kind enough to create a command line tool called occ that can manually add missing files and folders to the ownCloud database. You can run the following snippet on your server to check where this utility is located on the local file system:

find / -name "occ" 2>/dev/null  

Which outputs the following on my demo server:
OCC Binary Location

All you need to do is cd into that folder (in my case /var/www/owncloud) and run the following snippet:

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

Where www-data is the user your web server runs on.
And now, it is time for the results:

OCC Output From The Console

Positive Results In The Web Interface

YEAH!! So this command has definitely helped. Now you can add all your files directly into your ownCloud data folder without having to sync from the desktop client.