Problems backing up Oracle control files via DBD::Oracle 
Author Message
 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;
  my $rc;
  my $sql;

  $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;

Quote:
}

Here is some helpful output:

== syslog msg

ora-backup[20812]: Failed to backup control file for database SADB -
ORA-01580: error creating control backup file
/ora3/hotbackup/SADB_0220/control.ctl

== end syslog

== DBI trace log

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.

== end DBI trace

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



Tue, 10 Aug 2004 05:20:03 GMT  
 Problems backing up Oracle control files via DBD::Oracle
Quote:

> 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;
>   my $rc;
>   my $sql;

>   $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:

> == syslog msg

> ora-backup[20812]: Failed to backup control file for database SADB -
> ORA-01580: error creating control backup file
> /ora3/hotbackup/SADB_0220/control.ctl

> == end syslog

> == DBI trace log

> 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.

> == end DBI trace

> 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

Your problem is not with Perl or the DBD/DBI.  The problem is from
Oracle...

$ oerr ora 01580
01580, 00000, "error creating control backup file %s"
// *Cause:  An operating system error occurred while attempting to
create a
//          controlfile backup.
// *Action:  Check the error stack for more detailed information

In looking at your debug info from DBI, I see ...

 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   <<-- here is
the problem
SVR4 Error: 2: No such file or directory (DBD ERROR: OCIStmtExecute)'
on DBI::st=HASH(0x269cbc)

Gidyup!
--
Ron Reidy
Oracle DBA



Tue, 10 Aug 2004 13:51:17 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Problems backing up Oracle control files via DBD::Oracle

2. Problems with DBD::Oracle under Windows+Oracle 8

3. Problem setting LD_LIBRARY_PATH to point to the correct Oracle client lib for DBD::Oracle

4. problems installing DBD::oracle for oracle-db-access

5. DBD::Oracle problems on Linux with Oracle 8.0.5

6. DBD-Oracle: Problems connecting to Oracle

7. problems installing DBD::oracle for oracle-db-access

8. DBD::Oracle, and Oracle RDB

9. Building DBD::Oracle for Oracle 8

10. Using ORACLE DATE field with DBD-Oracle

11. Q: Can DBD::Oracle be used when Oracle TCP/IP access is disabled

12. DBD::Oracle for oracle 9i

 

 
Powered by phpBB® Forum Software