
Installgen
Features and Benefits
Installgen
Demo Available for download...

#!/usr/local/bin/perl
# program: prod1_archivelog_move_job.pl (renamed from 84_prod1_archivelog_move_job_1.pl)
# features: This script moves archivelog files more than 4
# hours old to another location.
# This script should only be used in situations
# where an RMAN backup is not going to be scheduled
# on the server. The RMAN backup will backup up and
# then clear the archivelog files.
# This script could be used on a standby server
# which is not performing RMAN backups.
#
# Notes: If a standby delay is implemented on the standby
# server, this delay time needs considered when setting
# the delay_hours variable in this program. The RFS
# process (Oracle 8.1.5 and higher) will copy
# archived logs immediately, but the logs will
# not be applied until the standby delay interval has elapsed.
#
# Usage: 1) Edit the destination directory path as needed
# 2) Add to CRON
#
# Script Sequence#: 84
# Used By: run every 4 hours via oracle UNIX account CRON job - on standby server
#
# ******** Move Standby Database Archivelogs Every 4 Hours ********
# 02 0,4,8,12,16,20 * * 0-6 /opt/server_scripts/prod1_archivelog_move_job.pl
#
# Copyright 2002 by .com Solutions Inc.
#
# --------------- Revision History ---------------
# Date By Changes
# 01-20-2002 dsimpson Initial Release
# 05-26-2002 dsimpson Updated for Solaris.
# This output file was created by Installgen version 1.38 on Sun Nov 10 14:51:56 2002. By .com Solutions Inc. www.dotcomsolutionsinc.net
use strict;
use File::Copy;
use File::stat;
my $delay_hours=.4; # Do not set delay_hours=0, to insure file is not currently being written by Oracle
my $seconds_per_hour= 60 * 60;
my $current_start_time = '';
my $max_mtime='';
my $archivelog_directory_path ="/archive";
my $destination_directory_path="/backup";
my @archivelog_directory_list=();
my @files_to_move=();
my $filename_item=();
my $inode='';
my $inode_mtime='';
my $temp_path1='';
my $temp_path2='';
# get current time
$current_start_time = time();
# calculate max modification time on file
$max_mtime=$current_start_time - ($delay_hours*$seconds_per_hour);
# get directory listing of archivelogs directory
opendir(DIR1,$archivelog_directory_path) || die ("Unable to open directory: $archivelog_directory_path");
@archivelog_directory_list=readdir(DIR1);
closedir(DIR1);
# find archivelog files in standby server directory which are old enough to be moved
foreach $filename_item (@archivelog_directory_list)
{
$temp_path1=$archivelog_directory_path."/".$filename_item;
$inode=stat($temp_path1);
$inode_mtime=$inode->mtime;
if (-f $temp_path1)
{
# the file is not a directory or symlink
# check to see if the file is old enough to move
push (@files_to_move,$filename_item) if $inode_mtime < $max_mtime;
}
}
# move files to alternate location
foreach $filename_item (@files_to_move)
{
print "File to move: $filename_item\n";
$temp_path1 = $archivelog_directory_path."/".$filename_item;
$temp_path2 = $destination_directory_path."/".$filename_item;
File::Copy::move("$temp_path1","$temp_path2");
}

