3

Motivation: owncloud-client fails periodically because of many reasons; I need scp during those events. In server, ls -la at $HOME

drwxr-xr-x 2 masi masi 4096 May 31 14:14 .
drwxr-xr-x 4 root root 4096 May 31 10:18 ..
-rw------- 1 masi masi 1099 May 31 12:20 .bash_history
-rw-r--r-- 1 masi masi  220 May 31 10:18 .bash_logout
-rw-r--r-- 1 masi masi 3512 May 31 10:18 .bashrc
-rw-r--r-- 1 masi masi  675 May 31 10:18 .profile
-rw------- 1 masi masi 2632 May 31 14:14 .viminfo

I can

I cannot for some reason

Where to SCP files?

Server: Raspberry Pi 3b. Client: Ubuntu 16.04.

Review of Ankit's answer

Client-side

masi@masi:~/Documents/Masi$ rsync -avz Directory -e ssh [email protected]:/home/masi/
sending incremental file list
Directory/
Directory/common_mistakes.tex

sent 484 bytes  received 58 bytes  63.76 bytes/sec
total size is 4,143  speedup is 7.64

Server-side

masi@raspberrypi:~ $ ls Directory/
common_mistakes.tex
masi@raspberrypi:~ $ sudo cp -r /home/masi/Directory /var/www/owncloud/data/masi/files/

masi@raspberrypi:~ $ sudo -u www-data php /var/www/owncloud/occ files:scan masi 
Scanning file   /masi/
Scanning folder /masi/
... 
Scanning file   /masi/files/Directory
...
Scanning folder /masi/files/Directory
Scanning file   /masi/files/Hematology/._common_mistakes.tex
Scanning file   /masi/files/Hematology/common_mistakes.tex
...
Scanning folder /masi/cache

where you have to have a complete path to occ. It works!

7
  • You have 50GB of documents on your client, that you want to put into owncloud server? You can upload with scp and then rescan on the server. However, I have no idea if the path your putting the files too is part of owncloud. It looks like a simply user home folder.
    – user508889
    May 31, 2016 at 16:37
  • 2
    I suggest rsync over ssh or sshfs help.ubuntu.com/community/rsync and digitalocean.com/community/tutorials/… and help.ubuntu.com/community/SSHFS . otherwise, IMHO, your question is too broad as there are probably 20 other options. Please ask a specific question about a specific option.
    – Panther
    May 31, 2016 at 16:45
  • 2
    Just install the owncloud desktop client, put the data in the synchronised directory, and wait.
    – fkraiem
    May 31, 2016 at 18:06
  • It's whatever directory you choose when installing the owncloud desktop client, and whose contents are synchronised with the server's.
    – fkraiem
    May 31, 2016 at 18:27
  • 2
    I think you should read this. doc.owncloud.org/desktop/2.1 (This is my last comment here.)
    – fkraiem
    Jun 1, 2016 at 6:09

2 Answers 2

6

Prerequisites:

  1. Data directory on the Owncloud server : Connect to server via ssh.If you have installed owncloud server to default location (/var/www), then go to the config file to find about the data directory location.

nano /var/www/owncloud/config/config.php

This file will tell you the location of the data directory (the place where all the files are stored.). Like this; Config.php file of owncloud

Now the Solution:

First, you can transfer the folder to the server using rsync and ssh. Its most convenient and fast (since compression is included). For example, from the local computer on the terminal use,

rsync -avz /path/to/local/50GBfolder -e ssh username@address:/home/user

Next, connect to server using ssh and from there copy folder to the owncloud data directory. (Two step are needed since you need root permission to copy to owncloud data directory which is owned by www-data user.)

Copy files this way;

sudo cp -r /home/user/50Gbfolder /path/to/data/$owncloud_username/files/

  • Inside the data directory, there is a folder for each owncloud user as owncloud_username, then under that there is a folder as files; hence mentioned above in the command.

Lastly, update owncloud database by scanning to identify the new files. This is done by prebuilt command. First, change directory to your owncloud installation directory. For default this is \var\www\owncloud. so,

cd \var\www\owncloud

If you do ls, you will see an executable as occ under this folder. This occ is a php based program.

To run occ for rescan,

sudo -u www-data php occ files:scan $user_name

Full rescan may take some time. After the rescan, you will see the folder when logged in from a browser.


Explanation:

  • rsync -avz /path/to/local/50GBfolder -e ssh username@address:/home/user

-a includes recursive, permissions, links, group etc and much more. Check man-page. -v verbose, -z compress and transfer.

  • sudo cp -r /home/user/50Gbfolder /path/to/data/$owncloud_username/files/

-r recursive folder copy, all subfolders are copied.

2
  • 1
    @Masi: First question: The path maybe different for your installation. The one I have mentioned is for default installation. Second question: For rsync -a includes -rlptgoD which is for recursive, links, preserve permission, preserve modification times, preserve group, preserve ownership, preserve device files. It is much more than -c. ManPage for rsync
    – ankit7540
    Jun 9, 2016 at 14:31
  • Thank you for the great explanation! I think I should be using rsync -avz. Jun 9, 2016 at 14:36
2

There are two problems with your scp command:

  • You are trying to upload a directory, hence you must provide the -r option (copy recursively).

  • The environment variables are substituted before the execution of the command. Therefore, $HOME in [email protected]:$HOME/ expands to the path of your home directory on your local (rather than the remote) machine. If the home directory paths on the two machines are different then the command will work not as you intended, most probably failing because of access problems. When using scp, refer to your home directory on the remote machine with '.' (in other words scp interprets paths on the remote machine relative to your home directory).

So the correct command will be:

scp -r $HOME/5GBdata/ [email protected]:.

However, note that this answer only points out your mistakes in using scp. Refer to the other answer(s) for recommendations on how to achieve your final goal.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .