cerebrou
cerebrou

Reputation: 5540

Sending files to smb server

I've got a server with an smb address, smb://files.cluster.ins.localnet/ Is it possible to send there files (fast) via the command line in a way similar to scp or rsync?

For example,

scp_to_samba folder_to_copy smb://files.cluster.ins.localnet/copied_content_folder/

Upvotes: 0

Views: 2847

Answers (1)

collineps
collineps

Reputation: 31

I haven't found a way to get either rsync or scp to play nice with Samba servers. Try using using smbclient -c as described in this answer:

smbclient //files.cluster.ins.localnet -c 'prompt OFF; recurse ON; lcd folder_to_copy; mkdir copied_content_folder; cd copied_content_folder; mput *'

If you're planning on communicating with the same server frequently and want something command-like, you could try something like this bash 'script':

#!/bin/bash
# scp_to_samba.sh

smbclient //files.cluster.ins.localnet -W domain -U username \
-c "prompt OFF; recurse ON; lcd $1; mkdir $2; cd $2; mput *"

where domain and username are whatever credentials you need to log on to your server. Usage would then be:

./scp_to_samba.sh folder_to_copy copied_content_folder

To copy back from the server, you'd need to switch a few things in that command/script and use mget instead of mput.

Is this 'fast'? I don't know. But it is pretty straightforward and has worked pretty well for me so far.

See the smbclient man page for more details.

Upvotes: 3

Related Questions