Scripts
#!/bin/bash
############################################################## XML ###############################################
rm -rf /home/DR_test/remonte_scp_xml.sh
rm -rf /home/DR_test/remonte_scp_jasper.sh
rm -rf /home/DR_test/remonte_scp_jrxml.sh
find /home/DR_test/mxl -name "*.xml">> /home/DR_test/demo_xml.log
ssh root@192.168.1.1 "bash -s"< /home/DR_test/remonte_xml.sh >> /home/DR_test/export_xml.log
file1="/home/DR_test/demo_xml.log"
file2="/home/DR_test/export_xml.log"
comm -23 $file1 $file2 >> /home/DR_test/test.log
c=`cat /home/DR_test/test.log | wc -l`
i=1
while [ $i -le $c ]
do
cat /home/DR_test/test.log |awk "FNR=="$i"" |awk '{print " scp -rp " $1 " root@192.168.1.1:" $1 }'>> /home/DR_test/remonte_scp_xml.sh
i=`expr $i + 1`
done
rm /home/DR_test/demo_xml.log
rm /home/DR_test/export_xml.log
rm /home/DR_test/test.log
############################################################## JASPER ###############################################
find /home/DR_test/mxl -name "*.jasper">> /home/DR_test/demo_jasper.log
ssh root@192.168.1.1 "bash -s"< /home/DR_test/remonte_jasper.sh >> /home/DR_test/export_jasper.log
file1="/home/DR_test/demo_jasper.log"
file2="/home/DR_test/export_jasper.log"
comm -23 $file1 $file2 >> /home/DR_test/test.log
c=`cat /home/DR_test/test.log | wc -l`
i=1
while [ $i -le $c ]
do
cat /home/DR_test/test.log |awk "FNR=="$i"" |awk '{print " scp -rp " $1 " root@192.168.1.1:" $1 }'>> /home/DR_test/remonte_scp_jasper.sh
i=`expr $i + 1`
done
rm /home/DR_test/demo_jasper.log
rm /home/DR_test/export_jasper.log
rm /home/DR_test/test.log
############################################################## JRXML ################################################
find /home/DR_test/mxl -name "*.jrxml">> /home/DR_test/demo_jrxml.log
ssh root@192.168.1.1 "bash -s"< /home/DR_test/remonte_jrxml.sh >> /home/DR_test/export_jrxml.log
file1="/home/DR_test/demo_jrxml.log"
file2="/home/DR_test/export_jrxml.log"
comm -23 $file1 $file2 >> /home/DR_test/test.log
c=`cat /home/DR_test/test.log | wc -l`
i=1
while [ $i -le $c ]
do
cat /home/DR_test/test.log |awk "FNR=="$i"" |awk '{print " scp -rp " $1 " root@192.168.1.1:" $1 }'>> /home/DR_test/remonte_scp_jrxml.sh
i=`expr $i + 1`
done
rm /home/DR_test/demo_jrxml.log
rm /home/DR_test/export_jrxml.log
rm /home/DR_test/test.log
sh /home/DR_test/remonte_scp_xml.sh
sh /home/DR_test/remonte_scp_jasper.sh
sh /home/DR_test/remonte_scp_jrxml.sh
find /home/DR_test/mxl -name "*.xml"
find /home/DR_test/mxl -name "*.jasper"
find /home/DR_test/mxl -name "*.jrxml"
Scripts Explanation
#!/bin/bash
############################################################## XML ###############################################
rm -rf /home/DR_test/remonte_scp_xml.sh
rm -rf /home/DR_test/remonte_scp_jasper.sh
rm -rf /home/DR_test/remonte_scp_jrxml.sh
find /home/DR_test/mxl -name "*.xml">> /home/DR_test/demo_xml.log
ssh root@192.168.1.1 "bash -s"< /home/DR_test/remonte_xml.sh (find /home/DR_test/mxl -name "*.xml") >> /home/DR_test/export_xml.log
file1="/home/DR_test/demo_xml.log"
file2="/home/DR_test/export_xml.log"
comm -23 $file1 $file2 >> /home/DR_test/test.log
c=`cat /home/DR_test/test.log | wc -l`
i=1
while [ $i -le $c ]
do
cat /home/DR_test/test.log |awk "FNR=="$i"" |awk '{print " scp -rp " $1 " root@192.168.1.1:" $1 }'>> /home/DR_test/remonte_scp_xml.sh
i=`expr $i + 1`
done
rm /home/DR_test/demo_xml.log
rm /home/DR_test/export_xml.log
rm /home/DR_test/test.log
XML
In XML script we have to copy all the xml files to DR site. First we have to take count and number of xml files in PROD and DR and store it in demo_xml.log and export_xml.log. Now compare this tow files and store the o/p in test.log file. Then take a count from test.log file and store it in a variable C and check with condition while 1 is less than or equal to variable C then copy the files from source to destination.
Scripts for JASPER
############################################################## JASPER ###############################################
find /home/DR_test/mxl -name "*.jasper">> /home/DR_test/demo_jasper.log
ssh root@192.168.1.1 "bash -s"< /home/DR_test/remonte_jasper.sh >> /home/DR_test/export_jasper.log
file1="/home/DR_test/demo_jasper.log"
file2="/home/DR_test/export_jasper.log"
comm -23 $file1 $file2 >> /home/DR_test/test.log
c=`cat /home/DR_test/test.log | wc -l`
i=1
while [ $i -le $c ]
do
cat /home/DR_test/test.log |awk "FNR=="$i"" |awk '{print " scp -rp " $1 " root@192.168.1.1:" $1 }'>> /home/DR_test/remonte_scp_jasper.sh
i=`expr $i + 1`
done
rm /home/DR_test/demo_jasper.log
rm /home/DR_test/export_jasper.log
rm /home/DR_test/test.log
JASPER
In Jasper script we have to copy all the jasper files to DR site. First we have to take count and number of jasper files in PROD and DR and store it in demo_jasper.log and export_jasper.log. Now compare this tow files and store the o/p in test.log file. Then take a count from test.log file and store it in a variable C and check with condition while 1 is less than or equal to variable C then copy the files from source to destination.
Scripts for JRXML
############################################################## JRXML ################################################
find /home/DR_test/mxl -name "*.jrxml">> /home/DR_test/demo_jrxml.log
ssh root@192.168.1.1 "bash -s"< /home/DR_test/remonte_jrxml.sh >> /home/DR_test/export_jrxml.log
file1="/home/DR_test/demo_jrxml.log"
file2="/home/DR_test/export_jrxml.log"
comm -23 $file1 $file2 >> /home/DR_test/test.log
c=`cat /home/DR_test/test.log | wc -l`
i=1
while [ $i -le $c ]
do
cat /home/DR_test/test.log |awk "FNR=="$i"" |awk '{print " scp -rp " $1 " root@192.168.1.1:" $1 }'>> /home/DR_test/remonte_scp_jrxml.sh
i=`expr $i + 1`
done
rm /home/DR_test/demo_jrxml.log
rm /home/DR_test/export_jrxml.log
rm /home/DR_test/test.log
sh /home/DR_test/remonte_scp_xml.sh
sh /home/DR_test/remonte_scp_jasper.sh
sh /home/DR_test/remonte_scp_jrxml.sh