PowerShell script exchange
Post Reply
dk-one
Novice
Posts: 9
Liked: never
Joined: Feb 13, 2018 10:27 am
Contact:

Unable to delete backup from disk with Powershell script before backup starts

Post by dk-one »

Given is a backup called "USB backup", the repository is simply called "USB".

This backup takes place once a weekend on a USB drive. Before the backup starts, it should simply delete the backup from the previous week.

I created a Powershell script that I run directly from the backup task (USB Backup => Storage => Advanced => Scripts => Run the following script before the job).

The Powershell script has the following content:

Code: Select all

Get-VBRBackup -Name "USB-Backup" | Remove-VBRBackup -FromDisk -Confirm:$false
When I call the script as admin via Powershell, it deletes the backup from the previous week.

However, when I start the backup job, Veeam says the job ran correctly, but the previous week's backup is not deleted.

I've already put the whole thing into a batch file but without success.

What am I doing wrong?
david.domask
Veeam Software
Posts: 2319
Liked: 556 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Unable to delete backup from disk with Powershell script before backup starts

Post by david.domask »

Hi dk-one,

The pre-job script should run under the same account as the Backup Service, which by default is SYSTEM; can you add some logging just to catch maybe like an access denied that might be happening, but printing whoami and a few try/catch statements I think will help figure out if it's about permissions.
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 38 guests