Senin, 05 Januari 2015

How to Rsync from window to Linux

How to Rsync from window to Linux

Install

Linux Ubuntu
#apt-get install rsync

Linux RHEL
#yum install rsync

Windows
-Install Cygwin
  - Net
      - OpenSSH
      - rsync

  - Admin
      - cygrunsrv

Run Cygwin bash
Clik start -> Cygwin -> Cygwin Terminal

#ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
90:c3:0e:c1:47:67:2b:23:f5:39:e7:1d:e6:4f:5f:b4 user@yourpc
The key’s randomart image is:
+–[ DSA 1024]—-+
| …o o |
| .+.= o |
| o.B = . o .|
| + = + + . ..|
| . S . o .E.|
| o ..|
| . .|
| |
| |
+—————–+

#scp /home/user/.ssh/id_rsa.pub root@192.168.10.9:~

On server linux

#touch /root/.ssh/authorized_keys
#cat /root/id_rsa.pub >> /root/.ssh/authorized_keys

On Windows at Cygwin bash shell

test rsync
#rsync -avz root@192.168.10.9:/data/backup/ /cygdrive/c/backup/

Create script/bat command start-from-windows.cmd at c:\opt\scripts\

c:\cygwin\bin\bash.exe -l -c "/cygdrive/c/opt/scripts/rsyncbck.sh

Create script/bash script rsyncbck.sh at c:\opt\scripts\

rsync -avz root@192.168.10.9:/data/backup/ /cygdrive/c/backup/

you can add schedule task on your windows