-
- Enthusiast
- Posts: 60
- Liked: 6 times
- Joined: Jul 29, 2010 8:34 am
- Full Name: Zed
- Contact:
Monitor Backup Copy job
Hello,
I searching for a script sample to monitor the continuous backup copy job status.
I want to report the succes, warning or failed status. I am not very aware about scripting so be cool with me.
Thanks.
Zed!
I searching for a script sample to monitor the continuous backup copy job status.
I want to report the succes, warning or failed status. I am not very aware about scripting so be cool with me.
Thanks.
Zed!
-
- Product Manager
- Posts: 20415
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Monitor Backup Copy job
Hi, Zed, using the following script you can the latest state of backup copy:
Thanks.
Code: Select all
asnp VeeamPSSNapin
$Job = Get-VBRJob -name "Name of backup copy Job"
$LastSession = $Job.FindLastSession()
$LastSession.State
-
- Enthusiast
- Posts: 60
- Liked: 6 times
- Joined: Jul 29, 2010 8:34 am
- Full Name: Zed
- Contact:
Re: Monitor Backup Copy job
Thanks.
I will try that and keep you aware.
Zed!
I will try that and keep you aware.
Zed!
-
- Product Manager
- Posts: 20415
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Monitor Backup Copy job
Be aware that the script provided is one time procedure, if you want to make it report on continuous basis, you will have to create a cycle. Thanks.
-
- Novice
- Posts: 6
- Liked: 3 times
- Joined: Oct 12, 2013 4:10 am
- Full Name: Toon Vandendriessche
- Contact:
Re: Monitor Backup Copy job
Hi,
With the FindLastSession() method it shows the state of the current running copy job. Since it's a continous job it's state is idle and Last Result value is None.
What i want to know is if the latest finished copy job was successfull.
I can do that now by getting all the sessions, sort by date and then select the second one, but it's cumbersome.
I think it would be better to change the method FindLastSession so that it displays the information of the latest finished session, not the currently running (idle state) session, or is there another way to achieve this?
With the FindLastSession() method it shows the state of the current running copy job. Since it's a continous job it's state is idle and Last Result value is None.
What i want to know is if the latest finished copy job was successfull.
I can do that now by getting all the sessions, sort by date and then select the second one, but it's cumbersome.
I think it would be better to change the method FindLastSession so that it displays the information of the latest finished session, not the currently running (idle state) session, or is there another way to achieve this?
-
- Product Manager
- Posts: 20415
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Monitor Backup Copy job
This is by design. The FindLastSession method returns the latest session, not the last finished one.I think it would be better to change the method FindLastSession so that it displays the information of the latest finished session, not the currently running (idle state) session, or is there another way to achieve this?
The approach described by you (second session, etc.) should do the trick:
Code: Select all
$Session = Get-VBRBackupSession | ? {$_.jobname -eq $Job.Name} | sort {$_.CreationTime} -Descending | select -first 2 | select -Last 1
$Session.Result
-
- Influencer
- Posts: 17
- Liked: 4 times
- Joined: Feb 14, 2018 12:01 pm
- Full Name: Elemer Gazda
- Contact:
Re: Monitor Backup Copy job
I am doing exactly as described above (Selecting 2nd last job to get the status of the Backup Copy job status).
However I want to fine tune this a bit.
Sometimes the Backup Copy interval can be quite long (7 days or 1 month), and because of this I want to achieve the folloiwing with powershell:
If the Endtime of the last backupCopy session is not 1/1/1900 than look at the results of the individual items (VMs) in the Backup Copy job and see if they are all successfull or not.
I haven't find the command to list the statuses of the VMs in the last BackupCopy session
This is what I have so far:
Any ideas?
P.S. $BackupCopyActiveJobs is acchieved by filtering down Backup Copy jobs which are not disabled.
However I want to fine tune this a bit.
Sometimes the Backup Copy interval can be quite long (7 days or 1 month), and because of this I want to achieve the folloiwing with powershell:
If the Endtime of the last backupCopy session is not 1/1/1900 than look at the results of the individual items (VMs) in the Backup Copy job and see if they are all successfull or not.
I haven't find the command to list the statuses of the VMs in the last BackupCopy session
This is what I have so far:
Code: Select all
$Sessions = Get-VBRBackupSession
$BackupCopySessionsLast = $Sessions | Where {$_.Jobtype -eq "BackupSync"} |Group-Object JobId | ForEach-Object {$_.Group | Sort-Object CreationTime -Descending | Select -First 1 }| Select *
ForEach($Job in $BackupCopyActiveJobs){
$EndTime = ($BackupCopySessionsLast | Where {$_.JobId -eq $Job.Id}).EndTime
If($EndTime -ne "01/01/1900"){
# Command to get the statuses of individual tasks (VMs) in the backup Copy Job
}
}
P.S. $BackupCopyActiveJobs is acchieved by filtering down Backup Copy jobs which are not disabled.
-
- Service Provider
- Posts: 49
- Liked: 15 times
- Joined: May 29, 2018 8:42 pm
- Contact:
Re: Monitor Backup Copy job
You want to look into task sessions which will give you per VM task information.
Code: Select all
$Sessions = Get-VBRBackupSession
$BackupCopySessionsLast = $Sessions | Where {$_.Jobtype -eq "BackupSync"} |Group-Object JobId | ForEach-Object {$_.Group | Sort-Object CreationTime -Descending | Select -First 1 }| Select *
ForEach($Job in $BackupCopyActiveJobs){
$EndTime = ($BackupCopySessionsLast | Where {$_.JobId -eq $Job.Id}).EndTime
If($EndTime -ne "01/01/1900"){
foreach($Task in $Job.GetTaskSessions()){
#Do Per VM Stuff
}
}
}
-
- Product Manager
- Posts: 20415
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Monitor Backup Copy job
This script returns names of VMs that have been successfully processed within the latest job session. You can incorporate this example in your code:
Thanks!
Code: Select all
Asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Name of your backup copy job"
$Session = $Job.FindLastSession()
$Session.GetTaskSessions() | where {$_.Status -eq "Success"} | select Name
Who is online
Users browsing this forum: No registered users and 7 guests