-
- Influencer
- Posts: 10
- Liked: never
- Joined: Oct 12, 2011 1:56 pm
- Full Name: Patrick
- Contact:
Powershell: Cancel Backup to tape job
Hi,
I am looking to write a Powershell script to cancel a Backup to tape jobs when the status is waiting for a tape. The problem is there are no configurable backup window in the GUI for the backup to tape. So when a tape is not present on a standalone drive, the job will never be canceled and the other B2T jobs are overlapped.
I wrote this script but it's not working. I think the GET-VBRTapeJob is not returning the state of a running backup to tape jobs. Could someone know how to get the status of a backup to tape job ?
-----------------------
Add-PSSnapin VeeamPSSnapin
$job = Get-VBRTapeJob | Where-Object {$_.State -like "WaitingTape"}
Stop-VBRJob $job
----------------------
I am looking to write a Powershell script to cancel a Backup to tape jobs when the status is waiting for a tape. The problem is there are no configurable backup window in the GUI for the backup to tape. So when a tape is not present on a standalone drive, the job will never be canceled and the other B2T jobs are overlapped.
I wrote this script but it's not working. I think the GET-VBRTapeJob is not returning the state of a running backup to tape jobs. Could someone know how to get the status of a backup to tape job ?
-----------------------
Add-PSSnapin VeeamPSSnapin
$job = Get-VBRTapeJob | Where-Object {$_.State -like "WaitingTape"}
Stop-VBRJob $job
----------------------
-
- VP, Product Management
- Posts: 27377
- Liked: 2800 times
- Joined: Mar 30, 2009 9:13 am
- Full Name: Vitaliy Safarov
- Contact:
Re: Powershell: Cancel Backup to tape job
Hello,
Have you had a chance to try this solution to report on the job state > Scheduled task to report on running backup jobs? That topic describes how to do that for regular jobs, but I assume the same parameters can be used for tape jobs as well.
Thanks!
Have you had a chance to try this solution to report on the job state > Scheduled task to report on running backup jobs? That topic describes how to do that for regular jobs, but I assume the same parameters can be used for tape jobs as well.
Thanks!
-
- Product Manager
- Posts: 20415
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Powershell: Cancel Backup to tape job
Yes, the job latest state can be gotten via .GetLastState() method. However, I'm not sure whether the corresponding information ("waiting for new tape") is reflected in this field. I don't have time to test it at the moment, so, you can do it yourself and see what particular status the tape job waiting for new tape has.
If the said method doesn't help, you will be able to get what you're after, using .logger parameter of backup session. Logger parameter allows you to see the exact information that is shown in the "action" pane.
Thanks.
If the said method doesn't help, you will be able to get what you're after, using .logger parameter of backup session. Logger parameter allows you to see the exact information that is shown in the "action" pane.
Thanks.
-
- Influencer
- Posts: 10
- Liked: never
- Joined: Oct 12, 2011 1:56 pm
- Full Name: Patrick
- Contact:
Re: Powershell: Cancel Backup to tape job
Yes, it working now. Here's the script:
Thanks for your help!
Code: Select all
Add-PSSnapin VeeamPSSnapin
$jobs = Get-VBRTapeJob
foreach($jobtoshow in $jobs)
{
if ($jobtoshow.GetLastState() -like "WaitingTape")
{
Stop-VBRJob $jobtoshow.name –runasync -Confirm:$false
}
}
-
- Product Manager
- Posts: 20415
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Powershell: Cancel Backup to tape job
I believe the script can be optimized even further, so that, it becomes an one-liner:
Hope this helps.
Thanks.
Code: Select all
Get-VBRTapeJob | ? {$_.GetLastState() -like "WaitingTape"} | Stop-VBRJob
Thanks.
-
- Enthusiast
- Posts: 38
- Liked: 4 times
- Joined: Aug 27, 2013 6:55 am
- Location: GER
- Contact:
Re: Powershell: Cancel Backup to tape job
hi, I`m also facing the problem with the pending backup to tape jobs, when the customer forgott to change the tape.
Could you shortly explain, how the script is used?
Do I have to create a windows task with this script that automatically runs after the start of the veaam copy to tape job?
thanks for help
Could you shortly explain, how the script is used?
Do I have to create a windows task with this script that automatically runs after the start of the veaam copy to tape job?
thanks for help
-
- Product Manager
- Posts: 20415
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Powershell: Cancel Backup to tape job
Yes, you can schedule the said script via Windows Scheduler to run some time after the tape job is executed. The script will find and stop those tape jobs that are sitting and waiting for a new tape.
Thanks.
Thanks.
-
- Enthusiast
- Posts: 38
- Liked: 4 times
- Joined: Aug 27, 2013 6:55 am
- Location: GER
- Contact:
Re: Powershell: Cancel Backup to tape job
The task with the script works quite well!
Thank you very much!
Thank you very much!
-
- Product Manager
- Posts: 20415
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Powershell: Cancel Backup to tape job
Glad to hear my input was helpful. Let me know, should other help be needed.
-
- Enthusiast
- Posts: 38
- Liked: 4 times
- Joined: Aug 27, 2013 6:55 am
- Location: GER
- Contact:
Re: Powershell: Cancel Backup to tape job
sadly since upgrading to B&R v.8 the script doesn`t work anymore
any hints for me to fix this again?
Thanks
edit: I found another thread: http://forums.veeam.com/powershell-f26/ ... 25450.html
can I fix my problem with something like this?!
any hints for me to fix this again?
Thanks
edit: I found another thread: http://forums.veeam.com/powershell-f26/ ... 25450.html
can I fix my problem with something like this?!
Get-VBRTapeJob | where {$_.LastState -eq "WaitingTape"} | Stop-VBRJob
-
- Product Manager
- Posts: 20415
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Powershell: Cancel Backup to tape job
Yes, but make sure to upgrade your installation to the latest product version first, as issues with LastState, LastResult showing incorrect values have been fixed there.
-
- Service Provider
- Posts: 56
- Liked: 6 times
- Joined: Apr 30, 2012 2:04 am
- Contact:
Re: Powershell: Cancel Backup to tape job
Looking at switching a client using Veeam 8 from BackupExec to Veeam for the tape component.
Is this PowerShell script still required, or is there an option within Veeam itself to wait only 30 minutes for a tape then cancel the job for example?
Is this PowerShell script still required, or is there an option within Veeam itself to wait only 30 minutes for a tape then cancel the job for example?
-
- Product Manager
- Posts: 20415
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Who is online
Users browsing this forum: No registered users and 15 guests