PowerShell script exchange
Post Reply
Ianm
Lurker
Posts: 2
Liked: never
Joined: Dec 06, 2011 11:22 am
Full Name: Ian Mawson
Contact:

Delete Job Via Powershell

Post by Ianm » 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

ThomasMc
Expert
Posts: 293
Liked: 17 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: Delete Job Via Powershell

Post by ThomasMc » 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

Ianm
Lurker
Posts: 2
Liked: never
Joined: Dec 06, 2011 11:22 am
Full Name: Ian Mawson
Contact:

Re: Delete Job Via Powershell

Post by Ianm » Dec 19, 2011 4:26 pm

But this asks a Yes / No question If I want to script it ???

ThomasMc
Expert
Posts: 293
Liked: 17 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: Delete Job Via Powershell

Post by ThomasMc » 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

Gostev
SVP, Product Management
Posts: 24813
Liked: 3573 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: Delete Job Via Powershell

Post by Gostev » 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!

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

Re: Delete Job Via Powershell

Post by mausger » 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

veremin
Product Manager
Posts: 16908
Liked: 1440 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Delete Job Via Powershell

Post by veremin » Dec 11, 2013 12:48 pm

Have you already checked this script that seems to answer your requirements? Thanks.

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

Re: Delete Job Via Powershell

Post by mausger » 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

veremin
Product Manager
Posts: 16908
Liked: 1440 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Delete Job Via Powershell

Post by veremin » Dec 11, 2013 3:42 pm

You are welcome. Feel free to ask, should any other questions arise. Thanks.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests