Hey everyone
because I did not find info about this and it took me a while to figure it out, I thought I write it down to let everyone know:
Situation & environment:
- intranet (1 Gbit/s) with NAS (Synology NAS)
- password based connection of clients to NAS (Synology policy)
- rsync (via ssh) and smb active
- rsync (via ssh) is VERY slow ( ~85 Mbit/s), especially with older NAS/slower NAS-CPUs (rsync tricks like -W, -z,… all tested, do not help)
- copying data via smb is fast (~940 Mbit/s)
- especially with single large files (eg. encrypted containers, 6-15 GB) the speed does not get better after several rsyncs (mod.date & size do not change) and everytime you do a rsync you get confronted with a speed of ~85 Mbit/s
Issue:
- I wanted to use the copy via smb command (copy files to NAS through smb) in my transfer- or backup-script (especially for the single large files)
- I did not find any usful info or help. Even this samba.org/man/smbclient did not help me (maybe too dumb
?)
Solution:
I figured it out and let you know (maybe you knew all of this already ages ago…).
use the command: smbclient
command in detail:
smbclient //server/name-of-share --user=username --password='pw123' --command='cd /path-inside-of-NAS-to-destination/ ; lcd /local-client-path-to-source/ ; put name-of-file ; exit'
command example:
smbclient //192.168.2.60/BackUp --user=usr1 --password='pw123' --command='cd /Encrypted/Cont/ ; lcd /home/usr1/Documents/Crypt/ ; put Cont1 ; exit'
(of course instead of: --user you can use -U. --command you can use -c)
the problems I had:
- //server/name-of-share: samba.org is describing this as //server/service, especially the term “service” was very misleading (samba.org: "service is the name of the service offered. Thus to connect to the service “printer” on the SMB/CIFS server ‘smbserver’, you would use the servicename //smbserver/printer "). I would prefer the name “share” rather than “printer”. Also you are not allowed to add a further path, like e.g. /share/shared-folder.
- paths cd and lcd: with “cd” you do not have to use the “/” as the first character, but with “lcd” you have to use it.
- name-of-file: Don’t forget the full-name, so if the name is “graphic.psd” it needs to have the “.psd” at the end.
- still a bad thing is, that you have to put in the pw…
Result:
So now you have more options!
This means that you can do “if-then”-statements in your script, which are (e.g.) based on the SIZE of the file or if it is an ENCRYPTED container or not, and for these files you can now use the “copy-through-smb” (smbclient-put) command and for all other files you can use the usual rsync.
That’s it.