PowerShell script exchange
Post Reply
FrankFoghMadsen
Novice
Posts: 5
Liked: never
Joined: Oct 08, 2015 6:25 am
Full Name: Frank Fogh Madsen
Location: Denmark
Contact:

Create new Workstation Job, fails with "Specify daily retention policy"

Post by FrankFoghMadsen »

Hi

When running this "simple" code i get an Error see below.

Code: Select all

$group = Get-VBRProtectionGroup -Name "TestGroupName"
$repository = Get-VBRBackupRepository -Name "Default Backup Repository"
$destination = New-VBRComputerDestinationOptions -OSPlatform Windows -BackupRepository $repository 

Add-VBRComputerBackupJob -OSPlatform Windows -Type Workstation -Mode ManagedByAgent -Name "TestJob" -BackupObject $group -BackupType EntireComputer -BackupRepository $repository -DestinationOptions $destination

Error -> 
Add-VBRComputerBackupJob : The specified computer backup job is invalid.
Failed to validate computer backup job. Specify daily retention policy
At line:5 char:1
+ Add-VBRComputerBackupJob -OSPlatform Windows -Type Workstation -Mode  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-VBRComputerBackupJob], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Veeam.Backup.PowerShell.Cmdlets.AddVBRComputerBackupJob
 

I've tryed everything , but i hopefully just are missing a simple thing , it is not a problem to create a windows server backup job with same parameters

/Frank

HannesK
Veeam Software
Posts: 5704
Liked: 782 times
Joined: Sep 01, 2014 11:46 am
Location: Austria
Contact:

Re: Create new Workstation Job, fails with "Specify daily retention policy"

Post by HannesK »

Hello,
and welcome to the forums.

the error message says, that the retention policy is missing

did you try Example 2: https://helpcenter.veeam.com/docs/backu ... ml?ver=100 ?

Best regards,
Hannes

FrankFoghMadsen
Novice
Posts: 5
Liked: never
Joined: Oct 08, 2015 6:25 am
Full Name: Frank Fogh Madsen
Location: Denmark
Contact:

Re: Create new Workstation Job, fails with "Specify daily retention policy"

Post by FrankFoghMadsen »

HI Hannes

yes it works fine when using Linux Options , but when changing OSPlatform to Windows i have the fail.

I've just uploaded a more simple example , so that it was easy to trouble shoot.

/Frank

FrankFoghMadsen
Novice
Posts: 5
Liked: never
Joined: Oct 08, 2015 6:25 am
Full Name: Frank Fogh Madsen
Location: Denmark
Contact:

Re: Create new Workstation Job, fails with "Specify daily retention policy"

Post by FrankFoghMadsen »

Here is the Code for the Job Part Same as in Example 2 but for Windows

Code: Select all

$group = Get-VBRProtectionGroup -Name "#DK01_PCC"

$repository = Get-VBRBackupRepository -Name "Default Backup Repository"

$destination = New-VBRComputerDestinationOptions -OSPlatform Windows -BackupRepository $repository

$daily = New-VBRDailyOptions -DayOfWeek Friday -Period 19:00

$schedule = New-VBRWindowsWorkstationScheduleOptions -DailyOptions $daily -PowerOffAction BackupAtPowerOn -BackupAtTargetConnection -PostBackupAction KeepRunning

Add-VBRComputerBackupJob -OSPlatform windows -Type Workstation -Mode ManagedByAgent -Name "windows" -BackupObject $group -BackupType EntireComputer -DestinationOptions $destination -ScheduleOptions $schedule -EnableSchedule

oleg.feoktistov
Veeam Software
Posts: 406
Liked: 130 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Create new Workstation Job, fails with "Specify daily retention policy"

Post by oleg.feoktistov »

Hi @FrankFoghMadsen,

I was able to reproduce the same issue in my lab with v10 P2 and going to discuss it with QA. So, it would be helpful to know your VBR version also.

Thanks,
Oleg

FrankFoghMadsen
Novice
Posts: 5
Liked: never
Joined: Oct 08, 2015 6:25 am
Full Name: Frank Fogh Madsen
Location: Denmark
Contact:

Re: Create new Workstation Job, fails with "Specify daily retention policy"

Post by FrankFoghMadsen »

Hi Oleg

I'm running V10 (10.0.0.4461) , Let me know if you need more info or need me to test more.

Thanks
Frank

oleg.feoktistov
Veeam Software
Posts: 406
Liked: 130 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Create new Workstation Job, fails with "Specify daily retention policy"

Post by oleg.feoktistov »

Hi Frank,

Decided to go for it once again with a clearer head and found the twist. Add-VBRComputerBackupJob cmdlet takes RestorePoints retention type by default. However, for windows workstations only RestoreDays retention type is allowed as described here. And for servers it is either of them. That's why it was working with other types. By the way, you also need to specify that daily schedule is enabled.
Lines amended:

Code: Select all

$schedule = New-VBRWindowsWorkstationScheduleOptions -PowerOffAction BackupAtPowerOn -DailyOptions $daily `
-BackupAtTargetConnection -PostBackupAction KeepRunning -EnableDailySchedule

Add-VBRComputerBackupJob -OSPlatform Windows -Type Workstation -Mode ManagedByAgent -Name "windows" `
-BackupObject $group -BackupType EntireComputer -DestinationOptions $destination `
-RetentionType RestoreDays -ScheduleOptions $schedule -EnableSchedule 
Cheers,
Oleg

FrankFoghMadsen
Novice
Posts: 5
Liked: never
Joined: Oct 08, 2015 6:25 am
Full Name: Frank Fogh Madsen
Location: Denmark
Contact:

Re: Create new Workstation Job, fails with "Specify daily retention policy"

Post by FrankFoghMadsen »

Hi Oleg

Perfect , that works.

Did't find that one myself , even had a second pair of eyes on it before posting.

Thanks for the help.

/Frank

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests