PowerShell script exchange
Post Reply
hovmaster105
Lurker
Posts: 2
Liked: never
Joined: Sep 11, 2022 8:18 pm
Full Name: björn Andersson
Contact:

Oracle PS Restore V11

Post by hovmaster105 »

Hi trying to help someone to set up a PS script that can restore an Oracle 12c database on Windows to a new location, however it seems to be a problem when the Original Oracle database is running as Local system and they don't have a Windows "Oracle Home Account" that i can use the password for.
In my test environment with an Oracle Home user and password "oracle1" it does work but trying it in production where it seems as if they run as "local system" it doesn't.
Or maybe i just don't understand how it works. Ideas?

Thanks

Code: Select all

$SecurePassword = "oracle1" | ConvertTo-SecureString -AsPlainText -Force
$RestorePoint = Get-VBRApplicationRestorePoint -Oracle -Name "WIN-RIJEQ72DR7U" | ?{$_.IsCorrupted -eq $False} | Sort-Object -Property CreationTime -Descending | Select -First 1
$Session = Start-VEORRestoreSession -RestorePoint $RestorePoint[0]
$Database = Get-VEORDatabase -Session $Session[0] -Name "TEST"
$NewDBPath = "C:\app\oracle\oradata\TESTR\"
$NewDBPathFRA = "C:\app\oracle\fast_recovery_area\testr\"
$FilesPath = Get-VEORDatabaseFile -Database $Database
$NewFilesPath = $FilesPath.Path -replace "^\w:\\.+\\(\w+\.\w+)","$NewDBPath`$1"
$NewFilesPath = $NewFilesPath -replace ".+\\(CONTROL02.CTL)","$NewDBPathFRA`$1"
$guestcreds = Get-VBRCredentials -Name ".\Administrator"
Restore-VEORDatabase -Database $Database -Server "WIN-RIJEQ72DR7U" -OracleSid "TESTR" -GlobalDatabaseName "TESTR" -OracleHome "C:\app\oracle\product\12.1.0\dbhome_1" -OracleHomePassword $SecurePassword -WindowsCredentials $GuestCreds -File $FilesPath -TargetPath $NewFilesPath -Force
#Restore-VEORDatabase -Database $Database -Server "WIN-RIJEQ72DR7U" -OracleSid "TESTR" -GlobalDatabaseName "TESTR" -OracleHome "C:\app\oracle\product\12.1.0\dbhome_1"  -WindowsCredentials $GuestCreds -File $FilesPath -TargetPath $NewFilesPath -Force
Stop-VEORRestoreSession -Session $Session[0]
PetrM
Veeam Software
Posts: 3264
Liked: 528 times
Joined: Aug 28, 2013 8:23 am
Full Name: Petr Makarov
Location: Prague, Czech Republic
Contact:

Re: Oracle PS Restore V11

Post by PetrM »

Hello Björn and Welcome to Veeam R&D Forums!

May I ask you to clarify what is the problem with this script? Do you see an error message or it does not show any output?

Thanks!
hovmaster105
Lurker
Posts: 2
Liked: never
Joined: Sep 11, 2022 8:18 pm
Full Name: björn Andersson
Contact:

Re: Oracle PS Restore V11

Post by hovmaster105 »

Hi

A clarification. Im running this script in a test environment just to get it right before i run it in prod.

Unless im using OracleHomePassword i get "username or password is incorrect"
So my guess it that in production where they run Oracle database under Local System i won't be able to use OracleHomePassword. Or am i wrong?

thanks
PetrM
Veeam Software
Posts: 3264
Liked: 528 times
Joined: Aug 28, 2013 8:23 am
Full Name: Petr Makarov
Location: Prague, Czech Republic
Contact:

Re: Oracle PS Restore V11

Post by PetrM »

Hello Björn,

Oracle home password must be used for Oracle 12c and later versions. There are no limitations to support databases under Local System. I wouldn't expect any issues if Oracle home password was specified.

Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests