Friday, July 17, 2015

Task:- Coping files from remote server to local server

Note: Its just a plan, not tested.
~~~ Task ~~~
Collect  /etc/passwd and /etc/group files from each of the servers and dump them into /var/tmp/env/{env}, where env is dev, test,uat,prod. File name you named as hostname.pw and hostname.gp so that it will be easier to sort based on the environment.


Planned Solution
1. First just run pm DEV servers to test.
- First test with single server

$ echo rplnxsje25 | while read host; do echo $host; scp -q  $host:/etc/passwd /tmp/$host.pw;  scp -q $host:/etc/group /tmp/$host.gp; done

define connection time out (ConnectTimeout) value in case server does not response.

$ echo arplnxsje25 | while read host; do echo $host; scp -q -o ConnectTimeout=3 -t $host:/etc/passwd /tmp/$host.pw;  scp -q -o ConnectTimeout=3 -t $host:/etc/group /tmp/$host.gp; done


2. Once its successful, try with multiple servers
- list of servers are on /var/tmp/env/dev .....

unix=unx
linux=lnx

$ for i in /var/tmp/env/hosts/{dev,test,demo,prod} ;do grep lnx $i ; done |\
 while read host; do echo $host \
 scp $host:/etc/passwd /var/tmp/hosts/pd.$host \
 scp $host:/etc/group /var/tmp/hosts/gp.$host
 done


ssh options
-q -o ConnectTimeout=3 -t

No comments:

Post a Comment