Thursday, November 20, 2014

data transfer using rsync

data transfer using rsync
This is tested from Solaris 10 to Solaris 11.2 server. [ M5000 to M10 server]

1. Include all the mountpoint that you want to transfer
$ cat /var/tmp/myFS.txt
/appdata/dev/appris1
/appdata/dev/appris2
/appdata/dev/davm

2. List the directories that you don't want to transfer. It must to relative path to the mountpoint.
$ cat /var/tmp/my.exclude
/hhpsc
/round3
/vendors
/logs/output

3. Have your simple script ready. Make sure to check one at a time. Once confirm, try with multiple mountpoints.
$ cat myrsync.all.sh
#!/bin/sh
D_HOST=he2unxpv401
C_FILE=/var/tmp/myFS.txt
for i in `cat ${C_FILE}`
do
        echo "Syncing $i to ${D_HOST} . Please wait ...."
        /usr/bin/rsync -logtprz --exclude-from=/var/tmp/my.exclude --progress --rsh='ssh -l root' $i root@${D_HOST}:$i
 # Solaris 11, we had an issue with root user. When you use sudo to root, its not really a user root, its a role. Convert root role to root user.
 #/usr/bin/rsync -logtprz --exclude-from=/var/tmp/my.exclude --progress --rsync-path="sudo rsync" --rsh='ssh -l your_userid' $i your_userid@${D_HOST}:$i
 #/usr/bin/rsync -logtprz --delete --update --progress --rsync-path="sudo rsync" --rsh='ssh -l dev' /app1/   dev@myappsas09:/app2/
done

4. Add/change below entry at the last line of /etc/ssh/sshd_config file
AuthorizedKeysFile /etc/ssh/authorized_keys/%u
and also allow root login by changing from no to yes on permit root login.
PermitRootLogin yes

5. Generate root key using ssh-keygen
# ssh-keygen -t dsa
Copy the public key from root user's home dir (solaris 10 its on / and solaris 11, its under /root) to target server's /var/tmp
again rename to root and copy to /etc/ssh/authorized_keys/

6. Test your connection with ssh to host and should not ask for password.
start your simple rsync and if it works use the script.
 

No comments:

Post a Comment