copy a folder under linux server to windows server

MS-Windows shared folder: You can share data between windows and linux system for such use : For example you would like to access MS-Windows share called //windowsserver/sharename by mounting to /mnt/win directory under Linux system. So execute these commands:

mkdir -p /mnt/win
mount -t smbfs -o username=winntuser,password=mypassword //windowsserver/sharename /mnt/win

Next create the password file /etc/sambapasswords:

cat > /etc/sambapasswords 
username = winntuser
password = mypassword

make sure that only root have access to it

chown root:root /etc/sambapasswords
chmod 600 /etc/sambapasswords

Add an entry to your /etc/fstab:

//windowserver/share /mnt/win smbfs
auto,gid=users,fmask=0664,dmask=0775,iocharset=iso8859-15, credentials=/etc/sambapasswords 0 0

Append an entry to your crontab like this, if you need to do a backup daily at 1AM:

0 1 * * * cp /path/to/yourbackup /mnt/win 

FTP solution: you may install a ftp server on your windows machine. filezilla server do perfectly the job. setup a ftp folder and an account with all required privileges. Later setup a file named ~/.netrc with this content:

machine windowserver
login ftpuser
password ftppassword

make sure that only root have access to it:

chown root:root ~/.netrc
chmod 600 ~/.netrc

Append to your backup script this lines that will transfer your backup file remotely to your ftp server:

ftp <<EOF
open windowserver
cd ${remote_path}
put ${filename}

Finally add your backup script to your crontab like what we did for first solution.

One thought on “copy a folder under linux server to windows server

  • October 15, 2013 at 11:51 am
      mount -t cifs // -o username=xyz,password=xyz12345 /mnt/win

Leave a Reply