Thursday, September 3, 2015

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' $iroot@${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.


Rsync:- sing rsync for migration


rsync on the same server,
tested on Linux
-n, --dry-run - perform a trial run with no changes made

rsync --avx --dry-run --exclude=/lost+found/ /opt/satle/ /opt/satle/ 2>&1>/var/tmp/myrsynclog.out &
/usr/bin/rsync -avx --exclude=/lost+found/ /opt/satle/ /opt/satle/ 2>&1 >/var/tmp/rsync_oracle1.out &

To different host
tested on solaris,
#!/bin/ksh
/usr/bin/rsync -logtprz --exclude-from=/var/tmp/rsync.exclude --progress --rsync-path="sudo rsync" --rsh='ssh -l jay' /opt/satle/ jay@sama:/opt/satle/
/usr/bin/rsync -logtprz --exclude-from=/var/tmp/rsync.exclude --progress --rsync-path="sudo rsync" --rsh='ssh -l jay' /opt/satle/ jay@sama:/opt/satle/
Include the directories that you don't want to rsync.
# cat var/tmp/rsync.exclude
/myexcldir/
/myedir/

source : http://linuxtab.blogspot.com/search?q=sudo

No comments:

Post a Comment