
Installgen
Features and Benefits
Installgen
Demo Available for download...
Bookmark This Page

#! /usr/local/bin/perl
# program: prod3_archivelog_move_job.pl (renamed from 84_prod3_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.
#
# Script Sequence#: 84
# Used By: run every 4 hours via AT scheduler
# Usage:
# ******** Move Primary Database Archivelogs Every 4 Hours ********
# AT 00:00 /every:M,T,W,Th,F,S,Su c:\server_scripts\prod3_archivelog_move_job.pl
# AT 04:00 /every:M,T,W,Th,F,S,Su c:\server_scripts\prod3_archivelog_move_job.pl
# AT 08:00 /every:M,T,W,Th,F,S,Su c:\server_scripts\prod3_archivelog_move_job.pl
# etc...
#
# Copyright 2002 by .com Solutions Inc.
#
# --------------- Revision History ---------------
# Date By Changes
# 01-20-2002 dsimpson Initial Release
# 06-20-2002 dsimpson Set default directories to archivelog and
# backup locations.
# Moving of files is now only dependent upon
# the age of the file, instead of comparing file
# sizes two times.
# Symlinks and enclosed directories regardless of
# name are not moved.
# This output file was created by Installgen version 1.38 on Thu Nov 14 17:16:25 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 = time();
my $max_mtime=$current_start_time - ($delay_hours*$seconds_per_hour);
my $archivelog_directory_path ="c:\\archive";
my $destination_directory_path="c:\\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");
}

