PowerShell script exchange
Post Reply
stani
Novice
Posts: 6
Liked: 2 times
Joined: Oct 26, 2017 7:29 am
Full Name: Stani YK CHEN
Contact:

RMAN backup return value with Start-VBRApplicationBackupJob

Post by stani »

when we using Start-VBRApplicationBackupJob to run the Oracle backup job, after the job finish, the returned value of EndTime always showing 01/01/1900 00:00:00 and the result is None

as replied from support:
"This is how the plugin job works with sessions. The active (it is more often in Idle) session is always one. Until the next start of the job, all session logs will be in it, at the next start, a history session is created (the active one is cloned, after which the clone ends and the original is reset). Therefore, nothing more suitable to return without serious changes in the job itself will not work. "

but I just wonder, if the DB backup itsef is a "sub-task", should it return the backup status after the backup task is done, instead wait until the whole session end? what we really care is whether the DB task is success or not, and how long is backup time taken. thanks

related Veeam support case no.:
# 05941252
# 06035017
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: RMAN backup return value with Start-VBRApplicationBackupJob

Post by PetrM »

Hi Stani,

May I ask you to elaborate a bit more on it? In particular, I'm interested why do you need PowerShell for it and why you cannot obtain the required information about DB backup task status and duration via GUI?

By design, the policy works in continuous mode and the history session is created right after policy restart, for example when the next scheduled incremental run is kicked off. In theory, we can get rid of this continuous mode in future versions but it will require a significant amount of engineering effort because the overall policy architecture must be redesigned.

As a workaround, you can try the following one-linear based on this cmdlet:

Code: Select all

Get-VBRTaskSession -Session $AppSession
where -Session parameter specifies the session the tasks of which you want to get.

Thanks!
stani
Novice
Posts: 6
Liked: 2 times
Joined: Oct 26, 2017 7:29 am
Full Name: Stani YK CHEN
Contact:

Re: RMAN backup return value with Start-VBRApplicationBackupJob

Post by stani »

Dear PetrM,

we use Control-M to trigger the backup with PowerShell command for central job scheduling and workload automations.

we did try the Get-VBRTaskSession -session command, but the result is weird, it cant reflect to the actual results from Get-VBRApplicationBackupJobSession

the Get-VBRTaskSession didnt retrive any results:

Code: Select all

PS C:\Windows\system32> Get-VBRApplicationBackupJobSession -name "Oracle_RMAN_RAC_D"
Name         : Oracle_RMAN_RAC_D
CreationTime : 27/04/2023 16:40:44
EndTime      : 27/04/2023 17:51:37
JobId        : c2bece84-0e84-424d-8a61-521a8f8b4d67
Result       : Success
State        : Stopped
Id           : d1ead572-01dc-4253-9475-8ce4331a3725
 
Name         : Oracle_RMAN_RAC_D
CreationTime : 27/04/2023 11:49:27
EndTime      : 27/04/2023 12:15:39
JobId        : c2bece84-0e84-424d-8a61-521a8f8b4d67
Result       : Warning
State        : Stopped
Id           : b5a4ad98-fe50-468e-a771-04090fe8d560
 
Name         : Oracle_RMAN_RAC_D
CreationTime : 27/04/2023 10:34:32
EndTime      : 27/04/2023 11:37:56
JobId        : fa79eb8b-c11f-4299-b921-80cafa877b67
Result       : Warning
State        : Stopped
Id           : 2d21a29c-1047-4c03-8b75-a6964e47789c

PS C:\Windows\system32> Get-VBRTaskSession -session d1ead572-01dc-4253-9475-8ce4331a3725
PS C:\Windows\system32> Get-VBRTaskSession -session b5a4ad98-fe50-468e-a771-04090fe8d560
PS C:\Windows\system32> Get-VBRTaskSession -session 2d21a29c-1047-4c03-8b75-a6964e47789c

the Get-VBRTaskSession results didnt match to that from Get-VBRApplicationBackupJobSession

Code: Select all

PS C:\Windows\system32> Get-VBRApplicationBackupJobSession -name "Oracle_RMAN_ora_d"
Name         : Oracle_RMAN_ORA_D
CreationTime : 03/05/2023 09:15:54
EndTime      : 01/01/1900 00:00:00
JobId        : c1c1cd70-e722-401b-a526-d18111c10dd5
Result       : None
State        : Idle
Id           : 6a297e2e-7ddd-42a7-9e04-63d292ca1b7b
 
Name         : Oracle_RMAN_ORA_D
CreationTime : 02/05/2023 09:15:14
EndTime      : 03/05/2023 09:15:54
JobId        : c1c1cd70-e722-401b-a526-d18111c10dd5
Result       : Success
State        : Stopped
Id           : 3af024c6-59d0-4508-8e4b-da489ff8bb58
 

Name         : Oracle_RMAN_ORA_D
CreationTime : 01/05/2023 09:14:54
EndTime      : 02/05/2023 09:15:14
JobId        : c1c1cd70-e722-401b-a526-d18111c10dd5
Result       : Success
State        : Stopped
Id           : b7683a12-037a-4500-91cd-65d2038d1d5d


PS C:\Windows\system32> Get-VBRTaskSession -session 6a297e2e-7ddd-42a7-9e04-63d292ca1b7b
Name                      Status         Operation
----                      ------         ---------
mdmsdb                    Success


PS C:\Windows\system32> Get-VBRTaskSession -session 3af024c6-59d0-4508-8e4b-da489ff8bb58
Name                      Status         Operation
----                      ------         ---------
mdmsdb                    Success

PS C:\Windows\system32> Get-VBRTaskSession -session b7683a12-037a-4500-91cd-65d2038d1d5d

Name                      Status         Operation
----                      ------         ---------
mdmsdb                    Success
 
PS C:\Windows\system32>
stani
Novice
Posts: 6
Liked: 2 times
Joined: Oct 26, 2017 7:29 am
Full Name: Stani YK CHEN
Contact:

Re: RMAN backup return value with Start-VBRApplicationBackupJob

Post by stani »

the usual result returned from Start-VBRApplicationBackupJob:

- the result is None
- state is working
- and the EndTime is 01/01/1900 00:00:00

Code: Select all

PS C:\Windows\system32> Start-VBRApplicationBackupJob - job "Oracle-RMAN-Plugin-SERVERNAME"
Name		: Oracle-RMAN-Plugin-SERVERNAME
CreationTime	: 14/03/2023 12:29:58
EndTime		: 01/01/1900 00:00:00
Jobld		: e2328c7d-4466-4bba-84cc-e951ca841d27
Result		: None
State		: Working
Id		: 99236763-8450-437-8991-3fceb767664e
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: RMAN backup return value with Start-VBRApplicationBackupJob

Post by PetrM »

Hi Stani,

Still not clear what is the purpose of using Control-M? Why don't simply schedule our policies directly in Veeam B&R console? Also, why do you need to get a task status for PS scheduling?

Get-VBRTaskSession -Session $AppSession works in your last example with the policy "Oracle-RMAN-Plugin-SERVERNAME". What's the difference between the policies "Oracle_RMAN_RAC_D" and "Oracle-RMAN-Plugin-SERVERNAME" ? Maybe the first one did not produce any backups?

Thanks!
stani
Novice
Posts: 6
Liked: 2 times
Joined: Oct 26, 2017 7:29 am
Full Name: Stani YK CHEN
Contact:

Re: RMAN backup return value with Start-VBRApplicationBackupJob

Post by stani » 1 person likes this post

Hi PetrM,

As per company policy, the Control-M team is responsible for deciding when a backup job should be run, but they should not have direct access to the Veeam server and VBR console. The Control-M will call the backup script provided by the backup server to trigger the backup job, and upon completion, the Control-M should receive a backup result indicating success, failure, or a warning."

As I have shown you above, if the backup job fails to run, the Get-VBRTaskSession will return nothing. For the second example, there are three different results (None, Success, and Success), but with Get-VBRTaskSession, all three sessions are showing Success. Is this normal?
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: RMAN backup return value with Start-VBRApplicationBackupJob

Post by david.domask » 1 person likes this post

Hi @stani,

This is a known behavior of the Plugins and how they handle sessions right now. On the session run, the session sits until the next session begins, then the old session is cloned and a new "active" session is created. (PM team: noted in issue 423374).

As Petr mentioned, right now this is just kind of the design of the Policies. It will perhaps change in future releases, but right now I guess let's consider it a request for change.

As an unsupported workaround, you can use the below code. Note that this workaround is not supported, so Veeam Support will not be able to assist with any items related to this code.

$PluginsJob = Get-VBRApplicationBackupJob #add in -Name or -Type to filter further and get your desired job
$PluginSessions = Get-VBRApplicationBackupJobSession -Name $PluginsJob.Name | Sort-Object -Property CreationTime -Descending | Select -First 1
$BackupSession = [Veeam.Backup.Core.CBackupSession]::Find($PluginSessions.id)

You can then check the properties on BackupSession for more details on what happened. You might check the output of Logger which has a method GetLog(). This in turn gives you a CTaskLogUpdates object which has the GetRecordsSortedByOrdinalID() method. You can parse on the statuses here for EFailed.

Similarly, if the job is in error, you can use the GetDetails() method on $BackupSession and it will return the error.

Again, I know this is not very clean, but right now what you're wanting to do is a bit of an edge case and fairly specific. The main problem is that the Plugin backups are a _Policy_ not a single job run, so that's why the reporting is a little bit different.
David Domask | Product Management: Principal Analyst
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: RMAN backup return value with Start-VBRApplicationBackupJob

Post by PetrM »

Hello,

@david.domask Thanks for the detailed answer and the provided workaround!

@stani Thanks for clarifying your use case but another question arises: if you need to use Control-M for the centralized management and scheduling, maybe you can switch over to standalone mode and call RMAN scripts on schedule directly on DB servers instead of using our policy? One of the main goals of RMAN policy is to enable centralized schedule and management from Veeam B&R console, maybe you should not mix two different solutions? So far it looks like you use one scheduler to trigger another scheduler that in turn launches backups.

To get a backup job session status, you can also try Get-VBRPluginBackupSession cmdlet (look at the Result field), it's a supported method by the way. This cmdlet is designed for standalone jobs but can also be used with a policy: in fact, a policy is just an "orchestration" tool for standalone jobs. The only downside of this method is that it provides reporting at the "per-server" level, with no way to see information for individual databases.

Thanks!
stani
Novice
Posts: 6
Liked: 2 times
Joined: Oct 26, 2017 7:29 am
Full Name: Stani YK CHEN
Contact:

Re: RMAN backup return value with Start-VBRApplicationBackupJob

Post by stani »

Hi David,

Thank you for providing the script reference. Our problem is the output does not match to the actual result.
I just wonder the VBR console can display the status of the database backup as well as its EndTime/duration properly, why the similar cannot be done with PS, or you can consider use a separated Cmdlet to retrieve such results instead resign of the architecture?
stani
Novice
Posts: 6
Liked: 2 times
Joined: Oct 26, 2017 7:29 am
Full Name: Stani YK CHEN
Contact:

Re: RMAN backup return value with Start-VBRApplicationBackupJob

Post by stani » 1 person likes this post

Hi Petr,

we prefer the managed mode over the standalone mode as it allows VBR and Veeam ONE to provide us a standardized backup report and history. Additionally, we would like to take advantage of the archivelog processing with VBR. On the other hand, when using standalone, each DB server requires to provide the repository credentials, which can be difficult to manage from a password management perspective.
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests