Sample Header Ad - 728x90

Import Oracle dump from Amazon RDS

-1 votes
1 answer
1041 views
I have successfully transferred my dump files to my RDS database instance based on http://d0.awsstatic.com/whitepapers/strategies-for-migrating-oracle-database-to-aws.pdf Now, I want to reverse this process: transfer files from RDS to linux server, from dump_file_dir to my local linux machine. I am aware there are only a few lines I need to change, but I couldn't get it to work. Any tips is appreciated. Original Perl script: use DBI; use warnings; use strict; # RDS instance info my $RDS_PORT=1521; my $RDS_HOST=""; my $RDS_LOGIN="/*******"; my $RDS_SID=""; #The $ARGV is a parameter you pass into the script my $dirname = "DATA_PUMP_DIR"; my $fname = $ARGV; my $data = "dummy"; my $chunk = 8192; my $sql_open = "BEGIN perl_global.fh := utl_file.fopen(:dirname, :fname, 'wb', :chunk); END;"; my $sql_write = "BEGIN utl_file.put_raw(perl_global.fh, :data, true); END;"; my $sql_close = "BEGIN utl_file.fclose(perl_global.fh); END;"; my $sql_global = "create or replace package perl_global as fhutl_file.file_type; end;"; my $conn = DBI->connect('dbi:Oracle:host='.$RDS_HOST.';sid='.$RDS_SID.';port='.$RDS_PORT,$RDS_LOGIN, '') || die ( $DBI::errstr . "\n"); my $updated=$conn->do($sql_global); my $stmt = $conn->prepare ($sql_open); $stmt->bind_param_inout(":dirname", \$dirname, 12); $stmt->bind_param_inout(":fname", \$fname, 12); $stmt->bind_param_inout(":chunk", \$chunk, 4); $stmt->execute() || die ( $DBI::errstr . "\n"); open (INF, $fname) || die "\nCan't open $fname for reading: $!\n"; binmode(INF); $stmt = $conn->prepare ($sql_write); my %attrib = ('ora_type','24'); my $val=1; while ($val> 0) { $val = read (INF, $data, $chunk); $stmt->bind_param(":data", $data , \%attrib); $stmt->execute() || die ( $DBI::errstr . "\n") ; }; die "Problem copying: $!\n" if $!; close INF || die "Can't close $fname: $!\n"; $stmt = $conn->prepare ($sql_close); $stmt->execute() || die ( $DBI::errstr . "\n") ;
Asked by user165576
Nov 25, 2016, 06:02 PM
Last activity: Nov 24, 2019, 03:52 PM