Delete Job Via Powershell

PowerShell script exchange

Delete Job Via Powershell

Veeam Logoby Ianm » Mon Dec 19, 2011 3:27 pm

I Veeam backup to a 3TB Drive then to Tape, every week I need to delete backup files and start again, leaving the job intact. So I regularly go into GUI and "Delete From Disk"

I started to look at Powershell to script it, but although I think it should be easy, I can't even get past GET-VBRJobObject !!!!

If I open Veeam Powershell and type GET-VBRJob I get a list of Jobs, If I then type GET-VBRJobOject it asks me for a Job, if I enter a job from the list I get errors

I have used some powershell in SQL but this doesn't make sense

Effectively I want to script two jobs and delete the files once a week from a scheduler
Ianm
Lurker
 
Posts: 2
Liked: never
Joined: Tue Dec 06, 2011 11:22 am
Full Name: Ian Mawson

Re: Delete Job Via Powershell

Veeam Logoby ThomasMc » Mon Dec 19, 2011 4:12 pm

You'll want to do this for v6
Code: Select all
Get-VBRBackup -Name "Backup Name" | Remove-VBRBackup -FromDisk -WhatIf


just drop the -whatif to commit the action as right now it's only telling you what it would have done
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: Delete Job Via Powershell

Veeam Logoby Ianm » Mon Dec 19, 2011 4:26 pm

But this asks a Yes / No question If I want to script it ???
Ianm
Lurker
 
Posts: 2
Liked: never
Joined: Tue Dec 06, 2011 11:22 am
Full Name: Ian Mawson

Re: Delete Job Via Powershell

Veeam Logoby ThomasMc » Mon Dec 19, 2011 5:38 pm

like this

Code: Select all
Get-VBRBackup -Name "Backup Name" | Remove-VBRBackup -FromDisk -WhatIf -Confirm:$false


again dropping the -whatif if your certain
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: Delete Job Via Powershell

Veeam Logoby Gostev » Mon Dec 19, 2011 8:48 pm

Ian, I guess Thomas just does not want to post a command that would immediately delete your backup from disk. If you are certain this is what you want to do, just remove the -WhatIf parameter from the original line. No questions will be asked in this case. Thanks!
Gostev
Veeam Software
 
Posts: 21390
Liked: 2349 times
Joined: Sun Jan 01, 2006 1:01 am
Location: Baar, Switzerland

Re: Delete Job Via Powershell

Veeam Logoby mausger » Tue Dec 10, 2013 9:09 pm

Hi guys

I have a similar problem.

I have a Backup job with a backup repository on a NAS which works fine.

Then i have a Backup Copy job to sync the backups to a RDX drive which works fine too, but only as long as we don not change the RDX cartidge.
When we change the cartridge we get a job fail because the previous backup files are not found.
As a temporary workaround we delete the backups on the RDX in the Veeam B&R GUI using "Remove from backups".
After that the Backup Copy Job works fine again.

So i want to script this with powershell to remove the backups of the Backup Copy job after the RDX cartridge has been changed and before the next sync starts.

I thried the commands posted here but the backups are not removed. They are still visible in the GUI and the Backup Copy job fails.

My Backup Copy job is named "Backup Copy from NAS to RDX"

The ps commands i already tried are:

Remove-VBRBackup -Backup "Backup Copy from NAS to RDX" -FromDisk -Confirm:$false
and
Get-VBRBackup -Name "Backup Copy from NAS to RDX" | Remove-VBRBackup -Confirm:$false

I only get an output similar to Get-VBRBackup without parameters which lists both backup jobs. One Backup Job to the NAS and one Backup Copy job from NAS to RDX, but no backups get removed

I also tried to start PS "as Administrator", same problem.

I have Veeam B&R 7.0 R2 installed on a Win2012 Hyper-V host.

Any ideas

Thanks
Martin
mausger
Novice
 
Posts: 8
Liked: 1 time
Joined: Tue Dec 10, 2013 8:48 pm
Full Name: Martin Ausserwoeger

Re: Delete Job Via Powershell

Veeam Logoby v.Eremin » Wed Dec 11, 2013 12:48 pm

Have you already checked this script that seems to answer your requirements? Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Delete Job Via Powershell

Veeam Logoby mausger » Wed Dec 11, 2013 3:34 pm

I have tried the script and it seems to work for me.
As far as i could test, the backups get deleted and a new full is created without error.

Thanks for the hint
mausger
Novice
 
Posts: 8
Liked: 1 time
Joined: Tue Dec 10, 2013 8:48 pm
Full Name: Martin Ausserwoeger

Re: Delete Job Via Powershell

Veeam Logoby v.Eremin » Wed Dec 11, 2013 3:42 pm

You are welcome. Feel free to ask, should any other questions arise. Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 3 guests