Here I am writing a script which most of the linux developer will make use of it.

Following script is implemented and tested with RedHat flavour of linux.

declare -A INSTANCES=(

["xxxx.xxxx.xxxx.xxxx"]="/path/apps/conf/"["xxxx.xxxx.xxxx.xxxy"]="/path/apps/conf/"

)
# INSTANCES is declarative array is SHELLSCript for key value pair.
# xxxx.xxxx.xxxx.xxxx be ip or hostname & /path/apps/conf/ be your location on which files to be copied
# similarily, xxxx.xxxx.xxxx.xxxy be your other ip or hostname & /path/apps/conf/ be your location on which files to be copied
REMOTE_LOGIN=ssh # Command used to connect remote machine
REMOTE_CP=scp    # Command used to remote copy
RSYNC=rsync     # Command for copy files with extended options
BK_TIME=`date +%d-%m-%Y-%H%M%S` # Creates backup constant literal
REMOTE_USER=ftpuser             # defines the remote user
for HOST in "${!INSTANCES[@]}"
do
 CONFPATH=${INSTANCES[$HOST]} # Fetches remote path declared in the array
 REMOTE_SERVER=$HOST
$REMOTE_LOGIN $REMOTE_USER@$REMOTE_SERVER << EOF
 date
 hostname
 su $APP_USER

 mkdir -p $CONFPATH/backup/$BK_TIME
 $RSYNC-avz --exclude backup $CONFPATH $CONFPATH/backup/$BK_TIME
EOF

echo " Configuration is copying to "$HOST"@"$CONFPATH
$REMOTE_CP -r conf $REMOTE_USER@$REMOTE_SERVER:$CONFPATH;

done