You are on page 1of 1

#!

/usr/bin/perl -w
#This script will create a rsync_runScript.sh file in /tmp.
#Copy this to the destination server and run the script.
#Storing the path of .dbf file in variable oradata
$oradata = '/export/u02/oracle/finuatdata'; #edit data location accordingly
$file = '/tmp/rsync_runScript.sh';
$target_dir = '/opt/oracl829/m1/test/rsync_dir';#edit accordingly
$user_name = 'finuat'; #edit accordingly
$source_server = `uname -n`;
chomp $source_server;
print( "source_server :$source_server" );
#Storing all .dbf filename along with path in an array
open (DAT, "ls $oradata/*.dbf & |");
@getdata=<DAT>;
close(DAT);
#Check if the array is empty
if(scalar( @getdata ) < 1)
{
print( "There is no .dbf files in this location\n $1\n" );
}
#If there are .dbf files
else
{
#Getting the length of path
$num = length ($oradata) + 1;
#for each data in array getdata
open FILE, ">$file" or die "unable to open $file $!";
print FILE "#Run this in target environment\n";
foreach $fname (@getdata)
{
chomp $fname;
$logname = substr $fname, $num;
$logname = substr ($logname, 0, -4);
print FILE ("/usr/local/bin/rsync --rsh=/usr/bin/ssh --archive --stats --whole-f
ile $user_name\@$source_server:$fname $target_dir >> $target_dir/log/$logname.lo
g & \nsleep 10\n");
}
}

You might also like