6

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?

4
  • 1
    You could mount the samba share on Ubuntu, then there is absolutely no difference on what OS the server is running.
    – Bruni
    Sep 24, 2015 at 7:06
  • sorry i don't have thoroughly knowledge of all this. will you please tell me what does it mean- mounting samba share?
    – d a i s y
    Sep 24, 2015 at 7:41
  • Mounting the samba share (the smb share) in your Ubuntu system, means that ubuntu will see the share as just another location seamlessly integrated in its filesystem. (it will just seam to be another folder). You could then run rsync just as usual.
    – Bruni
    Sep 24, 2015 at 7:54
  • 1
    help.ubuntu.com/community/MountWindowsSharesPermanently here you can find a detailed howto. Use cifs not smbfs.
    – Bruni
    Sep 24, 2015 at 8:17

2 Answers 2

18

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
1

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.

You must log in to answer this question.

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