Como passar o comando para o outro servidor usando o ssh

0
#!/bin/bash
ENV=stg
NODE=node4
KEYFILE=************
USERNAME=ubuntu
PORT=22
HOST=**********
CASSANDRA_HOME=/ebs/var/lib/cassandra
KEYSPACE=***
TABLE1=RegisterUser
TABLE2=EmailSyncMetadata
TABLE3=Emails
TABLE4=EmailsPerAccount
TABLE5=Modseq
TABLE6=EmailsTimeStamp
TABLE7=EmailsCronJobDetails
TABLE8=Users
TABLE9=UserSession
TABLE10=filter
TABLE11=CompleteContact
TABLE12=monitor
ssh -t -oStrictHostKeyChecking=no  -i $KEYFILE $USERNAME@$HOST -p $PORT 'sudo rm -r '$CASSANDRA_HOME'/data/'$KEYSPACE'/*/snapshots/*'
#remove the previous backup
#ssh -t -oStrictHostKeyChecking=no  -i $KEYFILE $USERNAME@$HOST -p $PORT 'sudo rm ' $CASSANDRA_HOME'/data/'$KEYSPACE'/*/backups/*'
#take the snapshot
ssh -t -oStrictHostKeyChecking=no  -i $KEYFILE $USERNAME@$HOST -p $PORT 'sudo sh /ebs/apps/pkgs/cassandra/bin/nodetool snapshot '$KEYSPACE
ssh -t -oStrictHostKeyChecking=no  -i $KEYFILE $USERNAME@$HOST -p $PORT 's3cmd del s3://inblox-cassandra-backup/'$ENV'/cassandra/'$NODE'/snapshots/*/*/*'
ssh -t -oStrictHostKeyChecking=no  -i $KEYFILE $USERNAME@$HOST -p $PORT 's3cmd del s3://inblox-cassandra-backup/'$ENV'/cassandra/'$NODE'/backups/*/*/*'

tables=( "emails" "registeruser" "modseq" "emailstimestamp" "emailscronjobdetails" "users" "usersession" "filter" "completecontact" )
for ((i=0; i<9; ++i )) ;
do
    a[$i]='basename $(ssh -t -oStrictHostKeyChecking=no  -i $KEYFILE $USERNAME@$HOST -p $PORT 'ls -d -Art '$CASSANDRA_HOME'/data/inblox/'${tables[$i]}'-* | tail -n 1')'
    #echo "${a[$i]}"
done
echo "start taking snapshot"
#------------------snapshot------------------------
for ((i=0; i<9; i++ )) ;
do
    #echo "${a[$i]}"
    ssh -v -t -oStrictHostKeyChecking=no  -i $KEYFILE $USERNAME@$HOST -p $PORT 's3cmd put -r '$CASSANDRA_HOME'/data/inblox/'${a[$i]}'/snapshots/* s3://inblox-cassandra-backup/'$ENV'/cassandra/'$NODE'/snapshots/''echo "${a[$i]}" | cut -d'-' -f 1''/'
    #echo "'echo "${a[$i]}" | cut -d'-' -f 1'"
done

Estou recebendo o seguinte resultado

Authenticated to 10.0.2.156 ([10.0.2.156]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
/snapshots/* s3://inblox-cassandra-backup/stg/cassandra/node4/snapshots/emailscronjobdetails/tails-7a91b6a0e8d711e4aa0fc793eb966f5b
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype [email protected] reply 0
debug1: channel 0: free: client-session, nchannels 1
Connection to 10.0.2.156 closed.
Transferred: sent 3408, received 2244 bytes, in 0.4 seconds
Bytes per second: sent 8165.4, received 5376.5
debug1: Exit status 0

na saída acima quando eu tentei executar o comando no outro servidor, apenas uma parte do comando está sendo transferida assim.

"/snapshots/* s3://inblox-cassandra-backup/stg/cassandra/node4/snapshots/emailscronjobdetails/tails-7a91b6a0e8d711e4aa0fc793eb966f5b"

no meu comando "tails-7a91b6a0e8d711e4aa0fc793eb966f5b" não está lá, mas está sendo adicionado durante a transferência para o servidor

    
por Ashwin G 05.05.2015 / 08:57

0 respostas

Tags