Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Problems backing up Oracle control files via DBD::Oracle
All,
I am attempting to use Perl DBI in conjunction with Perl DBD::Oracle to create a simple script to perform online Oracle backups.
So far I have successful written code to execute 99% of the tasks required for hot backups but have run into a snag with the final task of creating a backup copy of the control file.
To my knowledge the Oracle SQL command to perform this task is:
ALTER DATABASE BACKUP CONTROLFILE TO '/path/to/file'
and indeed this command does work when executed from within svrmgrl.
When I attempt to execute a similar command from with a Perl DBI script I encounter a number of errors (which will be included below).
Here is the Perl subroutine I put together to handle this task:
sub backup_control_file {
my $dbh = $_[ 0 ]; my $config = $_[ 1 ]; my $sref_err_msg = $_[ 2 ]; my $control_file;
$control_file = $config->get( 'base_backup_dir' ) . '/' . $config->get( 'backup_name' ) . '/' . 'control.ctl';
$sql = sprintf( "alter database backup controlfile to %s", $dbh->quote( $control_file ) );
$dbh->trace( 3, 'dbi-trace.log' );
$rc = $dbh->do( $sql );
$dbh->trace( 0, 'dbi-trace.log' );
unless ( $rc ) {
$$sref_err_msg = $dbh->errstr( );
return 0;
}
$debug && log_warning( "Control file for database " . $config->get( 'db_sid' ) . " backed up to " . $control_file );
return 1;
}
Here is some helpful output:
ora-backup[20812]: Failed to backup control file for database SADB - ORA-01580: error creating control backup file /ora3/hotbackup/SADB_0220/control.ctl
DBI::db=HASH(0x29db04) trace level set to 3 in DBI 1.14-nothread
-> do for DBD::Oracle::db (DBI::db=HASH(0x2bab64)~0x29db04 'alter
database backup controlfile to
'/ora3/hotbackup/SADB_0221/control.ctl'')
2 -> prepare for DBD::Oracle::db (DBI::db=HASH(0x29db04)~INNER
'alter database backup controlfile to
'/ora3/hotbackup/SADB_0221/control.ctl'' undef)
dbih_setup_handle(DBI::st=HASH(0x296660)=>DBI::st=HASH(0x269cbc), DBD::Oracle::st, 269cc8, Null!)
dbih_make_com(DBI::db=HASH(0x29db04), DBD::Oracle::st, 204)
dbd_st_prepare'd sql ALTER
dbd_describe skipped for ALTER
2 <- prepare= DBI::st=HASH(0x296660) at DBI.pm line 930.
-> execute for DBD::Oracle::st (DBI::st=HASH(0x296660)~0x269cbc)
dbd_st_execute ALTER (out0, lob0)...
ERROR EVENT 1580 'ORA-01580: error creating control backup file
/ora3/hotbackup/SADB_0221/control.ctl
ORA-27040: skgfrcre: create error, unable to create file
SVR4 Error: 2: No such file or directory (DBD ERROR: OCIStmtExecute)'
on DBI::st=HASH(0x269cbc)
!! ERROR: 1580 'ORA-01580: error creating control backup file
/ora3/hotbackup/SADB_0221/control.ctl
ORA-27040: skgfrcre: create error, unable to create file
SVR4 Error: 2: No such file or directory (DBD ERROR: OCIStmtExecute)'
<- execute= undef at DBI.pm line 931.
!! ERROR: 1580 'ORA-01580: error creating control backup file
/ora3/hotbackup/SADB_0221/control.ctl
ORA-27040: skgfrcre: create error, unable to create file
SVR4 Error: 2: No such file or directory (DBD ERROR: OCIStmtExecute)'
<- do= undef at ora-backup.pl line 352.
-> DESTROY for DBD::Oracle::st (DBI::st=HASH(0x269cbc)~INNER)
<- DESTROY= undef at ora-backup.pl line 354.
-> trace for DBD::Oracle::db (DBI::db=HASH(0x2bab64)~0x29db04 0
'dbi-trace.log')
<- trace= 3 at ora-backup.pl line 354.
I've checked things like permissions and existence of directories and come up blank. The only things I can think of is quoting issues when passing literal strings to the DBD::Oracle driver which should be solved by the use of the quote function.
Any helpful suggestions or comments are welcome,
Thanks Received on Thu Feb 21 2002 - 10:56:55 CST