Moved from andy/shelves to main WebMIP documentation area.

git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@6472 248e525c-4dfb-0310-94bc-949c084e9493
This commit is contained in:
hardya
2008-08-28 09:56:01 +00:00
parent 659bc637d4
commit 456f02a123
11 changed files with 411 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
REM $Id$
const archive_source = "\\advweb\archivelogs"
const archive_dest = "\\advwb2.opcs-online.info\archivelogs"
CopyArchives archive_source,archive_dest
Sub CopyArchives(strSource, strDest)
Dim fileSystem
Dim fldrSource
Dim fldrDest
set fileSystem = createobject("Scripting.FileSystemObject")
set fldrSource = fileSystem.GetFolder(strSource)
set fldrDest = fileSystem.GetFolder(strDest)
for each file in fldrSource.Files
WScript.Echo "Looking at " & file.Name
if not filesystem.FileExists(strDest & "\" & file.Name) then
file.Copy (strDest & "\" & file.Name)
end if
next
End Sub

View File

@@ -0,0 +1,10 @@
REM $Id$
set echo on
spool activatestandby.log
connect &&user/&&password as sysdba
alter database activate standby;
shutdown immediate;
startup mount;
alter database open;
spool off;
exit

View File

@@ -0,0 +1,132 @@
REM $Id$
const archive_source = "\\advweb\archivelogs"
const logship_user = "advweb\logship"
const logship_pwd = "logship"
const archive_dest = "\\advwb2.opcs-online.info\archivelogs"
const strFrom = "webmip@AdvanticaGroup.com"
const strTo = "Andrew.Hardy@AdvanticaGroup.com"
const strSub = "MIP: Logship"
const strSubError = "MIP: Logship Error"
strBody = "Logship Completed Successfully"
const strSMTP = "relay01.sleek.net"
CopyArchives archive_source,archive_dest, logship_user, logship_pwd
Sub CopyArchives(strSource, strDest, strUser, strPwd)
Dim strLocalDrive
strLocalDrive = "L:"
Dim strRemoteDrive
strRemoteDrive = "R:"
'error handling
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strLocalDrive, strSource, false, strUser, strPwd
'handle error
If Err.Number <> 0 Then
SendEmail strFrom, StrTo, strSubError, "Error Mapping " & strSource & ":" & Err.Description, StrSMTP
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
objNetwork.MapNetworkDrive strRemoteDrive, strDest, false, strUser, strPwd
'handle error
If Err.Number <> 0 Then
SendEmail strFrom, StrTo, strSubError, "Error Mapping " & strDest & ":" & Err.Description, StrSMTP
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
set fileSystem = createobject("Scripting.FileSystemObject")
WScript.Echo "Getting fldrSource"
set fldrSource = fileSystem.GetFolder(strLocalDrive)
'handle error
If Err.Number <> 0 Then
SendEmail strFrom, StrTo, strSubError, "Error Getting Local Folder " & strLocalDrive & ":" & Err.Description, StrSMTP
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
WScript.Echo "Getting fldrDest"
set fldrDest = fileSystem.GetFolder(strRemoteDrive)
'handle error
If Err.Number <> 0 Then
SendEmail strFrom, StrTo, strSubError, "Error Getting Remote Folder " & strRemoteDrive & ":" & Err.Description, StrSMTP
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
WScript.Echo "Looking at directory " & strSource
for each file in fldrSource.Files
if not filesystem.FileExists(strDest & "\" & file.Name) then
WScript.Echo "Copying " & file.Name & " to " & strDest & "\" & file.Name
file.Copy (strDest & "\" & file.Name)
end if
next
'handle error
If Err.Number <> 0 Then
SendEmail strFrom, StrTo, strSubError, "Error During File Copy:" & Err.Description, StrSMTP
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
objNetwork.RemoveNetworkDrive strRemoteDrive
'handle error
If Err.Number <> 0 Then
SendEmail strFrom, StrTo, strSubError, "Error Removing Remote Folder " & strRemoteDrive & ":" & Err.Description, StrSMTP
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
objNetwork.RemoveNetworkDrive strLocalDrive
'handle error
If Err.Number <> 0 Then
SendEmail strFrom, StrTo, strSubError, "Error Removing Local Folder " & strLocalDrive & ":" & Err.Description, StrSMTP
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
SendEmail strFrom, StrTo, strSub, strBody, StrSMTP
End Sub
' From the book "Windows Server Cookbook" by Robbie Allen
' ISBN: 0-596-00633-0
Sub SendEmail(strFrom, StrTo, strSub, strBody, StrSMTP)
set objEmail = CreateObject("CDO.Message")
objEmail.From = strFrom
objEmail.To = strTo
objEmail.Subject = strSub
objEmail.Textbody = strBody
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTP
objEmail.Configuration.Fields.Update
objEmail.Send
If Err.Number <> 0 Then
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
WScript.Echo "Email sent"
End Sub

View File

@@ -0,0 +1,132 @@
REM $Id$
const archive_dest = "\\advwb1.opcs-online.info\archivelogs"
const logship_user = "logship"
const logship_pwd = "logship"
const archive_source = "\\advwb2.opcs-online.info\archivelogs"
const strFrom = "webmip@AdvanticaGroup.com"
const strTo = "Andrew.Hardy@AdvanticaGroup.com"
const strSub = "MIP: Logship"
const strSubError = "MIP: Logship Error"
strBody = "Logship Completed Successfully"
const strSMTP = "relay01.sleek.net"
CopyArchives archive_source,archive_dest, logship_user, logship_pwd
Sub CopyArchives(strSource, strDest, strUser, strPwd)
Dim strLocalDrive
strLocalDrive = "L:"
Dim strRemoteDrive
strRemoteDrive = "R:"
'error handling
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strLocalDrive, strSource, false, strUser, strPwd
'handle error
If Err.Number <> 0 Then
SendEmail strFrom, StrTo, strSubError, "Error Mapping " & strSource & ":" & Err.Description, StrSMTP
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
objNetwork.MapNetworkDrive strRemoteDrive, strDest, false, strUser, strPwd
'handle error
If Err.Number <> 0 Then
SendEmail strFrom, StrTo, strSubError, "Error Mapping " & strDest & ":" & Err.Description, StrSMTP
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
set fileSystem = createobject("Scripting.FileSystemObject")
WScript.Echo "Getting fldrSource"
set fldrSource = fileSystem.GetFolder(strLocalDrive)
'handle error
If Err.Number <> 0 Then
SendEmail strFrom, StrTo, strSubError, "Error Getting Local Folder " & strLocalDrive & ":" & Err.Description, StrSMTP
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
WScript.Echo "Getting fldrDest"
set fldrDest = fileSystem.GetFolder(strRemoteDrive)
'handle error
If Err.Number <> 0 Then
SendEmail strFrom, StrTo, strSubError, "Error Getting Remote Folder " & strRemoteDrive & ":" & Err.Description, StrSMTP
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
WScript.Echo "Looking at directory " & strSource
for each file in fldrSource.Files
if not filesystem.FileExists(strDest & "\" & file.Name) then
WScript.Echo "Copying " & file.Name & " to " & strDest & "\" & file.Name
file.Copy (strDest & "\" & file.Name)
end if
next
'handle error
If Err.Number <> 0 Then
SendEmail strFrom, StrTo, strSubError, "Error During File Copy:" & Err.Description, StrSMTP
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
objNetwork.RemoveNetworkDrive strRemoteDrive
'handle error
If Err.Number <> 0 Then
SendEmail strFrom, StrTo, strSubError, "Error Removing Remote Folder " & strRemoteDrive & ":" & Err.Description, StrSMTP
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
objNetwork.RemoveNetworkDrive strLocalDrive
'handle error
If Err.Number <> 0 Then
SendEmail strFrom, StrTo, strSubError, "Error Removing Local Folder " & strLocalDrive & ":" & Err.Description, StrSMTP
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
SendEmail strFrom, StrTo, strSub, strBody, StrSMTP
End Sub
' From the book "Windows Server Cookbook" by Robbie Allen
' ISBN: 0-596-00633-0
Sub SendEmail(strFrom, StrTo, strSub, strBody, StrSMTP)
set objEmail = CreateObject("CDO.Message")
objEmail.From = strFrom
objEmail.To = strTo
objEmail.Subject = strSub
objEmail.Textbody = strBody
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTP
objEmail.Configuration.Fields.Update
objEmail.Send
If Err.Number <> 0 Then
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
WScript.Echo "Email sent"
End Sub

View File

@@ -0,0 +1,3 @@
REM $Id$
set ORACLE_SID=webmip
sqlplus /nolog @applylog

View File

@@ -0,0 +1,8 @@
REM $Id$
set echo on
spool s:\orabackup\webmip\scripts\applylog.log
connect sys/fmdidgad as sysdba
alter database recover automatic standby database until cancel;
alter database recover cancel;
spool off;
exit

View File

@@ -0,0 +1,4 @@
alter session set nls_date_format='DD-MON-YYYY HH24:MI:SS'
/
SELECT FIRST_TIME, FIRST_CHANGE#, NEXT_CHANGE#, SEQUENCE# FROM V$LOG_HISTORY
/

View File

@@ -0,0 +1,14 @@
REM $Id$
conn &&user/&&password as sysdba;
shutdown immediate;
conn &&user/&&password as sysdba;
startup mount;
alter database force logging;
alter system set log_archive_dest_1='location=s:\orabackup\webmip\archivelogs\' scope=both;
/*
set the time by which archive logs
should lag the redo in seconds
*/
alter system set archive_lag_target=2700;
alter database archivelog;
alter database open;

View File

@@ -0,0 +1,83 @@
REM $Id$
SET SERVEROUTPUT ON
store set set_settings.sql
set feedback off pagesize 0 heading off verify off
set linesize 100 trimspool on
DEFINE backup_dir = 's:\orabackup\webmip\files\'
REM Determine the oldest archive log to be backed up
archive log list;
alter system switch logfile;
REM
REM produce a SQL script that:
REM places each tablespace into 'backup' mode,
REM copies the contents of the tablespace to the
REM backup directory,
REM returns each tablespace from 'backup' mode
REM
PROMPT *** SPOOLING
spool do_backup.sql
WITH tsp_df AS (
SELECT tsp.tablespace_name
,df.file_name
,rownum AS current_row
,first_value(rownum) over(PARTITION BY tsp.tablespace_name) AS first_row
,last_value(rownum) over(PARTITION BY tsp.tablespace_name) AS last_row
FROM dba_tablespaces tsp
,dba_data_files df
WHERE tsp.contents <> 'TEMPORARY'
AND tsp.tablespace_name = df.tablespace_name
)
SELECT cmd
FROM (SELECT 'alter tablespace ' || tablespace_name || ' begin backup;' AS cmd
,tablespace_name
,1 AS seq
FROM tsp_df
WHERE current_row = first_row
UNION
SELECT 'host ocopy ' || file_name || ' &&backup_dir' AS cmd
,tablespace_name
,2 AS seq
FROM tsp_df
WHERE (current_row = first_row)
OR (current_row <> first_row AND current_row <> last_row)
OR (current_row = last_row AND last_row <> first_row)
UNION
SELECT 'alter tablespace ' || tablespace_name || ' end backup;' AS cmd
,tablespace_name
,3 AS seq
FROM tsp_df
WHERE current_row = last_row)
ORDER BY tablespace_name
,seq
/
spool off;
PROMPT *** SPOOLING COMPLETE
@set_settings
@@do_backup
REM
REM Create SQL script to add temporary files to temporary tablespaces
REM
set feedback off pagesize 0 heading off verify off
set linesize 100 trimspool on
spool create_tempfile$.sql
select 'alter tablespace '||ts.name||' add tempfile '''||df.name||''' size '|| df.bytes||' reuse;' from v$tempfile df, v$tablespace ts
where ts.ts# = df.ts#
/
spool off
host move create_tempfile$.sql &&backupdir\create_tempfiles.sql
@set_settings
REM
REM create control file for the standby database
REM create backup control file for the primary database
REM
alter database create standby controlfile as 's:\orabackup\webmip\files\standby.ctl';
alter database backup controlfile to 's:\orabackup\webmip\files\backup.ctl';
REM
REM create a database initialization script for
REM the standby database
REM
create pfile='s:\orabackup\webmip\files\initstandby.ora' from spfile;
REM
REM Determine the current archive log to be backed up
archive log list;
alter system switch logfile;

View File

@@ -0,0 +1 @@
oradim -NEW -SID webmip -STARTMODE manual

View File

@@ -0,0 +1,2 @@
REM $Id$
oradim -STARTUP -SID webmip -STARTTYPE srvc