If you are here, you've obviously started to use Owncloud and found that importing the mountain of data you want accessible is painful. So what if you have 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:
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.As you can see, we have multiple files in here. My ownCloud username is bart, so let's take a look in that folder.
Now this looks interesting. If I check my ownCloud web portal I can see that the directory structure is the same:
So I created a folder called TestFolder123 in the web interface and executed
ls -la
on the server's console.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:
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:
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.
Another option would be a command that scans a specific folder or user. In this example, the username is "bart" and the folder to scan is in the "files" directory called "temp2"
NOTE: the path is not the full path in the file system but must start with the username. For example my installation & data directory is located in /var/www/owncloud/data all the user data is located in a folders (named by username), followed by a "files" folder and then any folders/directories created there after for the given user.
If you try to use a fully qualified path afer --path directive, you will encounter the error
Unknown user 1 var
sudo -u www-data php occ files:scan --path bart/files/temp2
Further more, if you wanted to scan all the files and directories for a given user, you could run the following, where "bart" is the ownCloud username.
sudo -u www-data php occ files:scan bart
And now, it is time for the results:
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.
No comments:
Post a Comment