Transfer file to Windows server from Ubuntu

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