Transfer file to Windows server from Ubuntu

I am transferring file to Windows server from Ubuntu with following command:

smbclient //server_ip_add/share -U username

We can use rsync to transfer file from Ubuntu to Ubuntu and then by creating script run it as cronjob. Is it possible to do all this from Ubuntu to Windows?


I used MountWindowsSharesPermanently method to transfer file via rsync automatically.

First I mount a windows share folder (or map network drive) to which i want to transfer file with following method:

sudo mkdir /media/BACKUP
sudo mount -t cifs -o username=domainusername //ip_add/ShareFolder /media/BACKUP

then use rsync to transfer file:

sudo rsync -azp /path/to/source /media/BACKUP/ShareFolder

Create script,make it executable and schedule a cronjob.

Now if you reboot the system, it will be unmounted. So to mount it permanently, do following:

Open terminal & run:

sudo gedit /etc/fstab

Edit:

//ip_add/ShareFolder /media/BACKUP/ cifs credentials=/home/username/.smbcredentials,iocharset=utf8,gid=1000,uid=1000,file_mode=0777,dir_mode=0777,sec=ntlm 0 0

Here .smbcredentials is a credential file created in home directory

To create it, run gedit ~/.smbcredentials

Edit:

username=domainusername
password=Password

save & close it.

UPDATE: For Ubuntu 16.04.3, and 18.04, edit vers=1.0

//ip_add/ShareFolder /media/BACKUP/ cifs credentials=/home/username/.smbcredentials,iocharset=utf8,gid=1000,uid=1000,file_mode=0777,dir_mode=0777,vers=1.0,sec=ntlm 0 0

There is a tool for Windows that implements rsync. It is called cwrsync and is published by itefix.

It has packaged rsync and cygwin with the sole purpose to give a simple solution to install rsync on windows.

This link gives a step-by-step description of how to set it up and how to use it.

Obviously, itefix publish their own documentation.

I've used it successfully to copy 2GB+ of attachments over from a Ubuntu server to an IIS7 server. The attachments were part of a database application.