Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Raw device backup script
> but I need a script that backups over 20 raw devices
> datafiles to a TAPE without using a FS to store these
> datafiles first.
To a single tape or multiple ones? If it's a single tape then you are in for a real fun time trying to restore the stuff...
This is skeletal but should give you a reasonable starting point for a working backup:
#!/usr/bin/perl -w
$\ = "\n";
$, = "\n\t";
use Carp;
my @rawvolz =
qw(
/dev/foo
/dev/bar
);
sub run
{
for my $cmd ( @_ )
{
print "$$: system($cmd)";
if( my $exit = system($cmd) ) { print "STDERR: coredump" if $exit & 128; if( $exit < 0 ) { croak "$$: failed system call: $!"; } elsif( my $status = $exit >> 8 ) { croak "$$: Nonzero exit: $exit"; } elsif( my $signal = $exit & 0xFF ) { croak "$$: Zapped by SIG-$signal"; } }
sub mt
{
for my $cmd ( @_ )
{
if( system "mt $cmd" < 0 ) { croak "$$: Failed system call: $!"; } elsif( $? == 1 ) { croak "$$: Invalid tape device: $ENV{TAPE}"; } elsif( $? == 2 ) { croak "$$: Tape operation failed: $!"; } else { croak "$$: Flaky exit from mt: $!"; }
print "$$: Checking tape: $ENV{TAPE}";
# if these don't work there's little chance the backups will.
mt 'erase', 'status';
# ok., some hope, start the fireworks...
print "$$: Backing up:", @rawvolz;
my $blocksize = 1024 * 1024 * 80; # whatever
my $file = 0;
for my $raw ( @rawvolz )
{
# keep track of the file order for later restore.
print "$$: $raw :" . ++$file;
run qq{dd if='$raw' of='$ENV{TAPE}' obs='$blocksize'};
mt 'eof';
}
# avoid cinches in the tape and make sure not to overwrite # a valid backup with a new one if someone forgets to change # the tape.
mt 'retension', 'rewoffl';
# this isn't a module
0
__END__
-- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582 -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Steven Lembark INET: lembark_at_wrkhors.com Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Thu May 09 2002 - 15:26:35 CDT
![]() |
![]() |