PowerShell script exchange
Post Reply
johannesk
Expert
Posts: 146
Liked: 31 times
Joined: Jan 19, 2016 1:28 pm
Full Name: Jóhannes Karl Karlsson
Contact:

Powershell script for configuration backup

Post by johannesk »

Hi,

Does anyone here have a ready to use powershell script that can be scheduled to run a configuration backup of Veeam?

I then want to run it two times a day, each time targeting different storage location.

anyone?

Regards,
Jóhannes
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Powershell script for configuration backup

Post by jhoughes » 4 people like this post

You can run it with this code for each run, with examples for morning & evening, you will just need to adjust the first line to set each run to the appropriate repository.

Morning, 8AM example:

Code: Select all

$Repo = Get-VBRBackupRepository -Name '%reponame%'
$morningoptions = New-VBRDailyOptions -Type Everyday -Period 8:00
$morningschedule = New-VBRConfigurationBackupScheduleOptions -Type Daily -DailyOptions $morningoptions
Set-VBRConfigurationBackupJob -Repository $Repo --ScheduleOptions $morningschedule
Start-VBRConfigurationBackupJob
Evening, 8PM example:

Code: Select all

$Repo = Get-VBRBackupRepository -Name '%reponame%'
$eveningoptions = New-VBRDailyOptions -Type Everyday -Period 20:00
$eveningschedule = New-VBRConfigurationBackupScheduleOptions -Type Daily -DailyOptions $eveningoptions
Set-VBRConfigurationBackupJob -Repository $Repo --ScheduleOptions $morningschedule
Start-VBRConfigurationBackupJob
Husband, Father, Solutions Architect, Geek Extraordinaire | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
nielsengelen
Product Manager
Posts: 5619
Liked: 1177 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

Re: Powershell script for configuration backup

Post by nielsengelen » 1 person likes this post

You can change these via the built-in commands for configuration backup. You can then use Windows Task Manager to create a task to run the script when needed. Most likely it will be easier to create 2 separate scripts instead of 1 big script.
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
johannesk
Expert
Posts: 146
Liked: 31 times
Joined: Jan 19, 2016 1:28 pm
Full Name: Jóhannes Karl Karlsson
Contact:

Re: Powershell script for configuration backup

Post by johannesk »

Thanks Joe Houghes,

I'll give this a try - it seems to be exactly what I was looking for.

Regards,
Jóhannes
Leo0601
Enthusiast
Posts: 39
Liked: 2 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Need Powershell script for configuration backup in veeam 9.5 GA

Post by Leo0601 »

Hello,

I am going to uninstall veeam 9.5 and install the veeam 10 in the same server. Before going to uninstall the veeam 9.5, I need to take the configuration full backup and once after I complete the new installation of veeam 10. I have to restore the configuration backup in veeam 10.

So I need powershell script which take the configuration full backup in veeam 9.5.

Does anyone here have a ready to use powershell script that can be scheduled to run a configuration backup of Veeam 9.5 GA?

If anyone has please kindly share it here.

Thanks in advance.

Regards,
leo.
chris.arceneaux
VeeaMVP
Posts: 667
Liked: 358 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Georgia, USA
Contact:

Re: Powershell script for configuration backup

Post by chris.arceneaux » 1 person likes this post

Hi Leo,

Veeam provides PowerShell cmdlets to do that. The Start-VBRConfigurationBackupJob cmdlet is what you're looking for. It will kick off a configuration backup.

With that said, you won't be able to restore a configuration backup generated with v9.5 GA in v10. Per Veeam documentation, you must be running version 9.5 Update 3 or later. As such, you'll need to upgrade your current instance before proceeding.
bwisdom
Lurker
Posts: 2
Liked: never
Joined: Sep 30, 2020 5:25 pm
Full Name: Bobby Wisdom
Contact:

Re: Powershell script for configuration backup

Post by bwisdom »

If it would be better I can post this as a seperate post, but since this was here, I thought I would try this first.

How do the config backups work in terms of rollups? My boss keeps 30 days of configs and wants me to ship them off to azure. So Ill be removing the 30th and then adding in the new one with my script. Is it ok to just remove and add or is there some kind of rollup involved that I need to take into account?
ithark
Enthusiast
Posts: 29
Liked: 6 times
Joined: Sep 30, 2020 11:22 am
Full Name: Karthik
Contact:

Re: Powershell script for configuration backup

Post by ithark »

Hi Joe Houghes,
Good Day!
We also had a similar requirement for the config backup and we thought your script was just perfect for our needs.
But there is just onething which isn't working properly.
When we manually run the script it works like a charm but when the script is executed via the Task Scheduler, the config backup is always backed up to a single repository.
May I know if we are missing something here?
Thanks in advance!
Regards,
Karthik
Regards,
Karthik
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Powershell script for configuration backup

Post by jhoughes »

The sample code I gave was meant to have the repository name set for each run of the script.

Did you set the name correctly?
Husband, Father, Solutions Architect, Geek Extraordinaire | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
ithark
Enthusiast
Posts: 29
Liked: 6 times
Joined: Sep 30, 2020 11:22 am
Full Name: Karthik
Contact:

Re: Powershell script for configuration backup

Post by ithark »

Hi Joe,
Yes. As I mentioned, it runs fine if I run the script manually. But if it runs via the Task scheduler, the repository doesn't changes.
Regards,
Karthik
Regards,
Karthik
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Powershell script for configuration backup

Post by jhoughes »

Please post the code that you are running with Task Scheduler.
Husband, Father, Solutions Architect, Geek Extraordinaire | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
ithark
Enthusiast
Posts: 29
Liked: 6 times
Joined: Sep 30, 2020 11:22 am
Full Name: Karthik
Contact:

Re: Powershell script for configuration backup

Post by ithark »

Hi Joe,
It is resolved. I used the Clear-Variable in the script to delete the value of $Repo in both the script. Now it is running fine as expected.
Many thanks.
Regards,
Karthik
Regards,
Karthik
Leo0601
Enthusiast
Posts: 39
Liked: 2 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: Powershell script for configuration backup

Post by Leo0601 »

Hi chris

@chris.arceneaux

Thanks your reply. Its very useful.

I have one more query.

Veeam Case # 04777946

While I am trying to create Veeam backup job through powershell, Veeam backup get created for most of the products. For few products I am getting the below error. We have never faced this before. We have raised a ticket in veeam support. We have no clue.

--Cannot validate argument on parameter "entity" the argument is null provide a valid value for the argument and try running the command again--

When I am try to debug it, I have found one more thing like - the term 'Find-VBRViEntity' is not recognized as a name of a cmdlet. Not sure whether 'Find-VBRViEntity' cmdlet is deprecated or retired. I have proceed all the veeam module before I proceed these comments.

I am just struck.

Kindly help me to solve this issue. Looking forward for the replies.

Thanks in advance
Leo
Egor Yakovlev
Veeam Software
Posts: 2536
Liked: 680 times
Joined: Jun 14, 2013 9:30 am
Full Name: Egor Yakovlev
Location: Prague, Czech Republic
Contact:

Re: Powershell script for configuration backup

Post by Egor Yakovlev »

Hi Leo,

I have deleted 5 of identical posts of yours - please don't post same message in different threads.

As for your questions:
- Find-VBRVIEntity is present. If your machine does not find Veeam commandlets, make sure Veeam PowerShell Snapin(pre-v11) or Module(v11 onwards) is present.
- error you are receiving is a common null-value operation. Meaning your variable contains $null(aka has nothing).

/Thanks!
Leo0601
Enthusiast
Posts: 39
Liked: 2 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: Powershell script for configuration backup

Post by Leo0601 »

Hi Egor,

Thanks for your time.

Yeah got it. I wont post the same message in the different threads again.

I have checked the link which you shared me(https://helpcenter.veeam.com/docs/backu ... ml?ver=110). I tried the same and also module which I am trying through powershell script is present. When I am executing the particular line I am getting the output. Entity is which causing the issue. I have no clue.

Can you please help me to fix the issue.

Regards
Leo
Egor Yakovlev
Veeam Software
Posts: 2536
Liked: 680 times
Joined: Jun 14, 2013 9:30 am
Full Name: Egor Yakovlev
Location: Prague, Czech Republic
Contact:

Re: Powershell script for configuration backup

Post by Egor Yakovlev »

Can you please post the entire command that gives an error to you?
Does Get-VBRCommand returns results?
Leo0601
Enthusiast
Posts: 39
Liked: 2 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: Powershell script for configuration backup

Post by Leo0601 »

Hi Egor,

I am not getting any result for "Get-VBRCommand". Its throwing error like, the term 'Get-VBRCommand" is not recognized as a name of a cmdlet.

Backup job creating for all pools, except the management pool. Which was number 8 in below script.

I have attached my whole script below.

Please let me know if you need anything else

Code: Select all

-----------------------------------------------**Script Starts**----------------------------------------------------------

Add-PSSnapin VeeamPSSnapin

{

    while($True)
	{
		$siteID1 = Read-Host -Prompt "`nEnter the Site ID name "
		$siteID2 = Read-Host -Prompt "`nRe-Enter the Site ID name "
			if ($siteID1 -ne $siteID2) 
			{
				Write-Host "Value does not match.. Enter SiteID"	-fore Red
			}
			else
			{
				Break
			}
	}

	$ISEESiteID = $siteID1

Write-Host "________________________________________________________________"
Write-Host "`nSelect the application to create Backup Jobs "
Write-Host "`n1 - IntelliSpace Cardiovascular (ISCV)"
Write-Host "`n2 - IntelliSapce ECG (IECG)"
Write-Host "`n3 - Xper IM"
Write-Host "`n4 - IntelliSpace Concerto (Concerto)"
Write-Host "`n5 - DoseWise Portal"
Write-Host "`n6 - IntelliBridge Enterprise (IBE)"
Write-Host "`n7 - Performance Bridge"
Write-Host "`n8 - Management"
Write-Host "`n9 - Deployment Node"
Write-Host "`nTo Exit -> Ctrl + C " -fore Red

$Option = Read-Host -Prompt "`nEnter the option [Eg : 1 ]"



switch ( $Option )
{
    {($_ -eq "1")}
    {
        Clear
		Write-Host "`nCreating New Backup Job for IntelliSpace Cardiovascular (ISCV) Production...`n"
		$BackupJobName = "$($ISEESiteID)_Production_ISCV"
		$PlainPassword = Read-Host -assecurestring "`nEnter the cryptic password for encryption (please remember this password, since this cannot be restored once it is lost) :"
		$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
		$Key = Add-VBREncryptionKey -Password $SecurePassword -Description "Veeam Administrator"
		$Entity = Find-VBRViEntity -VMsAndTemplates -name *ISCV* | Where {$_.Name -NotMatch "TST"}
		$repository = Get-VBRBackupRepository
		Add-VBRViBackupJob -Name $BackupJobName -Entity $Entity -BackupRepository $repository
		$job = Get-VBRJob -Name $BackupJobName
		$options = $job.GetOptions()
		$options.BackupStorageOptions.RetainCycles = 8
		Set-VBRJobOptions -Job $job -Options $options
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedStorageOptions -CompressionLevel 5 -EnableDeduplication $True -StorageBlockSize 7
		$Options=$job.getoptions()
		$Options.GenerationPolicy.RecheckScheduleKind = "Monthly"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayOfWeek = "Sunday"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayNumberInMonth = "Last"
		$Options.GenerationPolicy.EnableRechek = $true
		$job.SetOptions($Options) | out-null
		Set-VBRJobAdvancedStorageOptions -Job $job -EnableEncryption $true -EncryptionKey $Key
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $True -EnableFullBackup $False -FullBackupDays Sunday
		Get-VBRJob -Name $BackupJobName | Set-VBRJobSchedule -Periodicaly -FullPeriod 12 -PeriodicallyKind Hours
		Get-VBRJob -Name $BackupJobName | Enable-VBRJobSchedule
        Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $True -EnableFullBackup $False -FullBackupDays Sunday -TransformToSyntethicDays Sunday
		Get-VBRJob -Name $BackupJobName | Disable-VBRJob
		
		
		Clear
		Write-Host "`nCreating New Backup Job for IntelliSpace Cardiovascular (ISCV) Test...`n"
		$BackupJobName = "$($ISEESiteID)_TEST_ISCV"
		$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
		$Key = Add-VBREncryptionKey -Password $SecurePassword -Description "Veeam Administrator"
		$Entity = Find-VBRViEntity -VMsAndTemplates -name *ISCV* | Where {$_.Name -Match "TST"}
		$repository = Get-VBRBackupRepository
		Add-VBRViBackupJob -Name $BackupJobName -Entity $Entity -BackupRepository $repository
		$job = Get-VBRJob -Name $BackupJobName
		$options = $job.GetOptions()
		$options.BackupStorageOptions.RetainCycles = 8
		Set-VBRJobOptions -Job $job -Options $options
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedStorageOptions -CompressionLevel 5 -EnableDeduplication $True -StorageBlockSize 7
		$Options=$job.getoptions()
		$Options.GenerationPolicy.RecheckScheduleKind = "Monthly"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayOfWeek = "Sunday"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayNumberInMonth = "Last"
		$Options.GenerationPolicy.EnableRechek = $true
		$job.SetOptions($Options) | out-null
		Set-VBRJobAdvancedStorageOptions -Job $job -EnableEncryption $true -EncryptionKey $Key
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $False -EnableFullBackup $True -FullBackupScheduleKind Monthly -DayNumberInMonth Last -DayOfWeek Saturday
		Get-VBRJob -Name $BackupJobName | Set-VBRJobSchedule -Monthly -At "4:00" -NumberInMonth Last -Days Saturday
		Get-VBRJob -Name $BackupJobName | Enable-VBRJobSchedule
		Get-VBRJob -Name $BackupJobName | Disable-VBRJob
    }
    {($_ -eq "2")}
    {
        Clear
		Write-Host "`nCreating New Backup Job for IntelliSapce ECG (IECG) Production...`n"
		$BackupJobName = "$($ISEESiteID)_Production_IECG"
		$PlainPassword = Read-Host -assecurestring "`nEnter the cryptic password for encryption (please remember this password, since this cannot be restored once it is lost) :"
		$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
		$Key = Add-VBREncryptionKey -Password $SecurePassword -Description "Veeam Administrator"
		$Entity = Find-VBRViEntity -VMsAndTemplates -name *IECG* | Where {$_.Name -NotMatch "TST"}
		$repository = Get-VBRBackupRepository
		Add-VBRViBackupJob -Name $BackupJobName -Entity $Entity -BackupRepository $repository
		$job = Get-VBRJob -Name $BackupJobName
		$options = $job.GetOptions()
		$options.BackupStorageOptions.RetainCycles = 8
		Set-VBRJobOptions -Job $job -Options $options
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedStorageOptions -CompressionLevel 5 -EnableDeduplication $True -StorageBlockSize 7
		$Options=$job.getoptions()
		$Options.GenerationPolicy.RecheckScheduleKind = "Monthly"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayOfWeek = "Sunday"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayNumberInMonth = "Last"
		$Options.GenerationPolicy.EnableRechek = $true
		$job.SetOptions($Options) | out-null
		Set-VBRJobAdvancedStorageOptions -Job $job -EnableEncryption $true -EncryptionKey $Key
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $True -EnableFullBackup $False -FullBackupDays Sunday
		Get-VBRJob -Name $BackupJobName | Set-VBRJobSchedule -Daily -At "00:00"
		Get-VBRJob -Name $BackupJobName | Enable-VBRJobSchedule
        Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $True -EnableFullBackup $False -FullBackupDays Sunday -TransformToSyntethicDays Sunday
		Get-VBRJob -Name $BackupJobName | Disable-VBRJob
		
		
		Clear
		Write-Host "`nCreating New Backup Job for IntelliSapce ECG (IECG) Test...`n"
		$BackupJobName = "$($ISEESiteID)_Test_IECG"
		$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
		$Key = Add-VBREncryptionKey -Password $SecurePassword -Description "Veeam Administrator"
		$Entity = Find-VBRViEntity -VMsAndTemplates -name *IECG* | Where {$_.Name -Match "TST"}
		$repository = Get-VBRBackupRepository
		Add-VBRViBackupJob -Name $BackupJobName -Entity $Entity -BackupRepository $repository
		$job = Get-VBRJob -Name $BackupJobName
		$options = $job.GetOptions()
		$options.BackupStorageOptions.RetainCycles = 8
		Set-VBRJobOptions -Job $job -Options $options
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedStorageOptions -CompressionLevel 5 -EnableDeduplication $True -StorageBlockSize 7
		$Options=$job.getoptions()
		$Options.GenerationPolicy.RecheckScheduleKind = "Monthly"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayOfWeek = "Sunday"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayNumberInMonth = "Last"
		$Options.GenerationPolicy.EnableRechek = $true
		$job.SetOptions($Options) | out-null
		Set-VBRJobAdvancedStorageOptions -Job $job -EnableEncryption $true -EncryptionKey $Key
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $False -EnableFullBackup $True -FullBackupScheduleKind Monthly -DayNumberInMonth Last -DayOfWeek Saturday
		Get-VBRJob -Name $BackupJobName | Set-VBRJobSchedule -Monthly -At "4:00" -NumberInMonth Last -Days Saturday
		Get-VBRJob -Name $BackupJobName | Enable-VBRJobSchedule
		Get-VBRJob -Name $BackupJobName | Disable-VBRJob
	}
	{($_ -eq "3")}
    {
        Clear
		Write-Host "`nCreating New Backup Job for Xper IM Production...`n"
		$BackupJobName = "$($ISEESiteID)_Production_XperIM"
		$PlainPassword = Read-Host -assecurestring "`nEnter the cryptic password for encryption (please remember this password, since this cannot be restored once it is lost) :"
		$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
		$Key = Add-VBREncryptionKey -Password $SecurePassword -Description "Veeam Administrator"
		$Entity = Find-VBRViEntity -VMsAndTemplates -name *XPERD* | Where {$_.Name -NotMatch "TST"}
		$repository = Get-VBRBackupRepository
		Add-VBRViBackupJob -Name $BackupJobName -Entity $Entity -BackupRepository $repository
		$job = Get-VBRJob -Name $BackupJobName
		$options = $job.GetOptions()
		$options.BackupStorageOptions.RetainCycles = 8
		Set-VBRJobOptions -Job $job -Options $options
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedStorageOptions -CompressionLevel 5 -EnableDeduplication $True -StorageBlockSize 7
		$Options=$job.getoptions()
		$Options.GenerationPolicy.RecheckScheduleKind = "Monthly"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayOfWeek = "Sunday"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayNumberInMonth = "Last"
		$Options.GenerationPolicy.EnableRechek = $true
		$job.SetOptions($Options) | out-null
		Set-VBRJobAdvancedStorageOptions -Job $job -EnableEncryption $true -EncryptionKey $Key
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $True -EnableFullBackup $False -FullBackupDays Sunday
		Get-VBRJob -Name $BackupJobName | Set-VBRJobSchedule -Daily -At "00:00"
	    Get-VBRJob -Name $BackupJobName | Enable-VBRJobSchedule
        Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $True -EnableFullBackup $False -FullBackupDays Sunday -TransformToSyntethicDays Sunday
		Get-VBRJob -Name $BackupJobName | Disable-VBRJob
		
		
		Clear
		Write-Host "`nCreating New Backup Job for Xper IM Production TEST...`n"
		$BackupJobName = "$($ISEESiteID)_Test_XperIM"
		$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
		$Key = Add-VBREncryptionKey -Password $SecurePassword -Description "Veeam Administrator"
		$Entity = Find-VBRViEntity -VMsAndTemplates -name *XPERD* | Where {$_.Name -Match "TST"}
		$repository = Get-VBRBackupRepository
		Add-VBRViBackupJob -Name $BackupJobName -Entity $Entity -BackupRepository $repository
		$job = Get-VBRJob -Name $BackupJobName
		$options = $job.GetOptions()
		$options.BackupStorageOptions.RetainCycles = 8
		Set-VBRJobOptions -Job $job -Options $options
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedStorageOptions -CompressionLevel 5 -EnableDeduplication $True -StorageBlockSize 7
		$Options=$job.getoptions()
		$Options.GenerationPolicy.RecheckScheduleKind = "Monthly"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayOfWeek = "Sunday"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayNumberInMonth = "Last"
		$Options.GenerationPolicy.EnableRechek = $true
		$job.SetOptions($Options) | out-null
		Set-VBRJobAdvancedStorageOptions -Job $job -EnableEncryption $true -EncryptionKey $Key
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $False -EnableFullBackup $True -FullBackupScheduleKind Monthly -DayNumberInMonth Last -DayOfWeek Saturday
		Get-VBRJob -Name $BackupJobName | Set-VBRJobSchedule -Monthly -At "4:00" -NumberInMonth Last -Days Saturday
		Get-VBRJob -Name $BackupJobName | Enable-VBRJobSchedule
		Get-VBRJob -Name $BackupJobName | Disable-VBRJob
		
	}
	{($_ -eq "4")}
    {
        Clear
		Write-Host "`nCreating New Backup Job for IntelliSpace Enterprise (Concerto) Production...`n"
		$BackupJobName = "$($ISEESiteID)_Production_Concerto"
		$PlainPassword = Read-Host -assecurestring "`nEnter the cryptic password for encryption (please remember this password, since this cannot be restored once it is lost) :"
		$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
		$Key = Add-VBREncryptionKey -Password $SecurePassword -Description "Veeam Administrator"
		$Entity = Find-VBRViEntity -VMsAndTemplates -name *ISP* | Where {$_.Name -NotMatch "TST"}
		$repository = Get-VBRBackupRepository
		Add-VBRViBackupJob -Name $BackupJobName -Entity $Entity -BackupRepository $repository
		$job = Get-VBRJob -Name $BackupJobName
		$options = $job.GetOptions()
		$options.BackupStorageOptions.RetainCycles = 8
		Set-VBRJobOptions -Job $job -Options $options
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedStorageOptions -CompressionLevel 5 -EnableDeduplication $True -StorageBlockSize 7
		$Options=$job.getoptions()
		$Options.GenerationPolicy.RecheckScheduleKind = "Monthly"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayOfWeek = "Sunday"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayNumberInMonth = "Last"
		$Options.GenerationPolicy.EnableRechek = $true
		$job.SetOptions($Options) | out-null
		Set-VBRJobAdvancedStorageOptions -Job $job -EnableEncryption $true -EncryptionKey $Key
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $False -EnableFullBackup $False -FullBackupDays Sunday
		Get-VBRJob -Name $BackupJobName | Disable-VBRJobSchedule 
		Get-VBRJob -Name $BackupJobName | Disable-VBRJob
		
		
		Clear
		Write-Host "`nCreating New Backup Job for IntelliSpace Enterprise (Concerto) TEST...`n"
		$BackupJobName = "$($ISEESiteID)_Test_Concerto"
		$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
		$Key = Add-VBREncryptionKey -Password $SecurePassword -Description "Veeam Administrator"
		$Entity = Find-VBRViEntity -VMsAndTemplates -name *ISP* | Where {$_.Name -Match "TST"}
		$repository = Get-VBRBackupRepository
		Add-VBRViBackupJob -Name $BackupJobName -Entity $Entity -BackupRepository $repository
		$job = Get-VBRJob -Name $BackupJobName
		$options = $job.GetOptions()
		$options.BackupStorageOptions.RetainCycles = 8
		Set-VBRJobOptions -Job $job -Options $options
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedStorageOptions -CompressionLevel 5 -EnableDeduplication $True -StorageBlockSize 7
		$Options=$job.getoptions()
		$Options.GenerationPolicy.RecheckScheduleKind = "Monthly"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayOfWeek = "Sunday"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayNumberInMonth = "Last"
		$Options.GenerationPolicy.EnableRechek = $true
		$job.SetOptions($Options) | out-null
		Set-VBRJobAdvancedStorageOptions -Job $job -EnableEncryption $true -EncryptionKey $Key
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $False -EnableFullBackup $False -FullBackupScheduleKind Monthly -DayNumberInMonth Last -DayOfWeek Sunday
		Get-VBRJob -Name $BackupJobName | Set-VBRJobSchedule -Periodicaly -FullPeriod 12 -PeriodicallyKind Hours
		Get-VBRJob -Name $BackupJobName | Disable-VBRJobSchedule
		Get-VBRJob -Name $BackupJobName | Disable-VBRJob
	}
	{($_ -eq "5")}
    {
        Clear
		Write-Host "`nCreating New Backup Job for DoseWise Portal Production...`n"
		$BackupJobName = "$($ISEESiteID)_Production_DoseWisePortal"
		$PlainPassword = Read-Host -assecurestring "`nEnter the cryptic password for encryption (please remember this password, since this cannot be restored once it is lost) :"
		$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
		$Key = Add-VBREncryptionKey -Password $SecurePassword -Description "Veeam Administrator"
		$Entity = Find-VBRViEntity -VMsAndTemplates -name *DWPAP* | Where {$_.Name -NotMatch "TST"}
		$repository = Get-VBRBackupRepository
		Add-VBRViBackupJob -Name $BackupJobName -Entity $Entity -BackupRepository $repository
		$job = Get-VBRJob -Name $BackupJobName
		$options = $job.GetOptions()
		$options.BackupStorageOptions.RetainCycles = 8
		Set-VBRJobOptions -Job $job -Options $options
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedStorageOptions -CompressionLevel 5 -EnableDeduplication $True -StorageBlockSize 7
		$Options=$job.getoptions()
		$Options.GenerationPolicy.RecheckScheduleKind = "Monthly"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayOfWeek = "Sunday"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayNumberInMonth = "Last"
		$Options.GenerationPolicy.EnableRechek = $true
		$job.SetOptions($Options) | out-null
		Set-VBRJobAdvancedStorageOptions -Job $job -EnableEncryption $true -EncryptionKey $Key
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $True -EnableFullBackup $False -FullBackupDays Sunday
		Get-VBRJob -Name $BackupJobName | Set-VBRJobSchedule -Daily -At "00:00"
		Get-VBRJob -Name $BackupJobName | Enable-VBRJobSchedule
        Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $True -EnableFullBackup $False -FullBackupDays Sunday -TransformToSyntethicDays Sunday
		Get-VBRJob -Name $BackupJobName | Disable-VBRJob
		
		
		Clear
		Write-Host "`nCreating New Backup Job for DoseWise Portal Test...`n"
		$BackupJobName = "$($ISEESiteID)_Test_DoseWisePortal"
		$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
		$Key = Add-VBREncryptionKey -Password $SecurePassword -Description "Veeam Administrator"
		$Entity = Find-VBRViEntity -VMsAndTemplates -name *DWPTST* | Where {$_.Name -Match "TST"}
		$repository = Get-VBRBackupRepository
		Add-VBRViBackupJob -Name $BackupJobName -Entity $Entity -BackupRepository $repository
		$job = Get-VBRJob -Name $BackupJobName
		$options = $job.GetOptions()
		$options.BackupStorageOptions.RetainCycles = 8
		Set-VBRJobOptions -Job $job -Options $options
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedStorageOptions -CompressionLevel 5 -EnableDeduplication $True -StorageBlockSize 7
		$Options=$job.getoptions()
		$Options.GenerationPolicy.RecheckScheduleKind = "Monthly"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayOfWeek = "Sunday"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayNumberInMonth = "Last"
		$Options.GenerationPolicy.EnableRechek = $true
		$job.SetOptions($Options) | out-null
		Set-VBRJobAdvancedStorageOptions -Job $job -EnableEncryption $true -EncryptionKey $Key
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $False -EnableFullBackup $True -FullBackupScheduleKind Monthly -DayNumberInMonth Last -DayOfWeek Saturday
		Get-VBRJob -Name $BackupJobName | Set-VBRJobSchedule -Monthly -At "4:00" -NumberInMonth Last -Days Saturday
		Get-VBRJob -Name $BackupJobName | Enable-VBRJobSchedule
		Get-VBRJob -Name $BackupJobName | Disable-VBRJob
	}
	{($_ -eq "6")}
    {
        Clear
		Write-Host "`nCreating New Backup Job for ISEE - IntelliBridge Enterprise (IBE) Production...`n"
		$BackupJobName = "$($ISEESiteID)_Production_IntelliBridge"
		$PlainPassword = Read-Host -assecurestring "`nEnter the cryptic password for encryption (please remember this password, since this cannot be restored once it is lost) :"
		$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
		$Key = Add-VBREncryptionKey -Password $SecurePassword -Description "Veeam Administrator"
		$Entity = Find-VBRViEntity -VMsAndTemplates -name *IBE* | Where {$_.Name -NotMatch "TST"}
		$repository = Get-VBRBackupRepository
		Add-VBRViBackupJob -Name $BackupJobName -Entity $Entity -BackupRepository $repository
		$job = Get-VBRJob -Name $BackupJobName
		$options = $job.GetOptions()
		$options.BackupStorageOptions.RetainCycles = 8
		Set-VBRJobOptions -Job $job -Options $options
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedStorageOptions -CompressionLevel 5 -EnableDeduplication $True -StorageBlockSize 7
		$Options=$job.getoptions()
		$Options.GenerationPolicy.RecheckScheduleKind = "Monthly"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayOfWeek = "Sunday"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayNumberInMonth = "Last"
		$Options.GenerationPolicy.EnableRechek = $true
		$job.SetOptions($Options) | out-null
		Set-VBRJobAdvancedStorageOptions -Job $job -EnableEncryption $true -EncryptionKey $Key
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $True -EnableFullBackup $False -FullBackupDays Sunday
		Get-VBRJob -Name $BackupJobName | Set-VBRJobSchedule -Daily -At "00:00"
		Get-VBRJob -Name $BackupJobName | Enable-VBRJobSchedule
        Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $True -EnableFullBackup $False -FullBackupDays Sunday -TransformToSyntethicDays Sunday
		Get-VBRJob -Name $BackupJobName | Disable-VBRJob
		
		
		Clear
		Write-Host "`nCreating New Backup Job for ISEE - IntelliBridge Enterprise (IBE) TEST...`n"
		$BackupJobName = "$($ISEESiteID)_Test_IntelliBridge"
		$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
		$Key = Add-VBREncryptionKey -Password $SecurePassword -Description "Veeam Administrator"
		$Entity = Find-VBRViEntity -VMsAndTemplates -name *IBE* | Where {$_.Name -Match "TST"}
		$repository = Get-VBRBackupRepository
		Add-VBRViBackupJob -Name $BackupJobName -Entity $Entity -BackupRepository $repository
		$job = Get-VBRJob -Name $BackupJobName
		$options = $job.GetOptions()
		$options.BackupStorageOptions.RetainCycles = 8
		Set-VBRJobOptions -Job $job -Options $options
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedStorageOptions -CompressionLevel 5 -EnableDeduplication $True -StorageBlockSize 7
		$Options=$job.getoptions()
		$Options.GenerationPolicy.RecheckScheduleKind = "Monthly"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayOfWeek = "Sunday"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayNumberInMonth = "Last"
		$Options.GenerationPolicy.EnableRechek = $true
		$job.SetOptions($Options) | out-null
		Set-VBRJobAdvancedStorageOptions -Job $job -EnableEncryption $true -EncryptionKey $Key
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $False -EnableFullBackup $True -FullBackupScheduleKind Monthly -DayNumberInMonth Last -DayOfWeek Saturday
		Get-VBRJob -Name $BackupJobName | Set-VBRJobSchedule -Monthly -At "4:00" -NumberInMonth Last -Days Saturday
		Get-VBRJob -Name $BackupJobName | Enable-VBRJobSchedule
		Get-VBRJob -Name $BackupJobName | Disable-VBRJob
		
    }
	{($_ -eq "7")}
    {
        Clear
		Write-Host "`nCreating New Backup Job for Performance Bridge Production...`n"
		$BackupJobName = "$($ISEESiteID)_Production_PerformanceBridge"
		$PlainPassword = Read-Host -assecurestring "`nEnter the cryptic password for encryption (please remember this password, since this cannot be restored once it is lost) :"
		$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
		$Key = Add-VBREncryptionKey -Password $SecurePassword -Description "Veeam Administrator"
		$Entity = Find-VBRViEntity -VMsAndTemplates -name *PB* | Where {$_.Name -NotMatch "TST"}
		$repository = Get-VBRBackupRepository
		Add-VBRViBackupJob -Name $BackupJobName -Entity $Entity -BackupRepository $repository
		$job = Get-VBRJob -Name $BackupJobName
		$options = $job.GetOptions()
		$options.BackupStorageOptions.RetainCycles = 8
		Set-VBRJobOptions -Job $job -Options $options
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedStorageOptions -CompressionLevel 5 -EnableDeduplication $True -StorageBlockSize 7
		$Options=$job.getoptions()
		$Options.GenerationPolicy.RecheckScheduleKind = "Monthly"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayOfWeek = "Sunday"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayNumberInMonth = "Last"
		$Options.GenerationPolicy.EnableRechek = $true
		$job.SetOptions($Options) | out-null
		Set-VBRJobAdvancedStorageOptions -Job $job -EnableEncryption $true -EncryptionKey $Key
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $True -EnableFullBackup $False -FullBackupDays Sunday
		Get-VBRJob -Name $BackupJobName | Set-VBRJobSchedule -Daily -At "00:00"
		Get-VBRJob -Name $BackupJobName | Enable-VBRJobSchedule
        Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $True -EnableFullBackup $False -FullBackupDays Sunday -TransformToSyntethicDays Sunday
		Get-VBRJob -Name $BackupJobName | Disable-VBRJob
		
		
		Clear
		Write-Host "`nCreating New Backup Job for Performance Bridge Test...`n"
		$BackupJobName = "$($ISEESiteID)_Test_PerformanceBridge"
		$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
		$Key = Add-VBREncryptionKey -Password $SecurePassword -Description "Veeam Administrator"
		$Entity = Find-VBRViEntity -VMsAndTemplates -name *PB* | Where {$_.Name -Match "TST"}
		$repository = Get-VBRBackupRepository
		Add-VBRViBackupJob -Name $BackupJobName -Entity $Entity -BackupRepository $repository
		$job = Get-VBRJob -Name $BackupJobName
		$options = $job.GetOptions()
		$options.BackupStorageOptions.RetainCycles = 8
		Set-VBRJobOptions -Job $job -Options $options
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedStorageOptions -CompressionLevel 5 -EnableDeduplication $True -StorageBlockSize 7
		$Options=$job.getoptions()
		$Options.GenerationPolicy.RecheckScheduleKind = "Monthly"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayOfWeek = "Sunday"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayNumberInMonth = "Last"
		$Options.GenerationPolicy.EnableRechek = $true
		$job.SetOptions($Options) | out-null
		Set-VBRJobAdvancedStorageOptions -Job $job -EnableEncryption $true -EncryptionKey $Key
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $False -EnableFullBackup $True -FullBackupScheduleKind Monthly -DayNumberInMonth Last -DayOfWeek Saturday
		Get-VBRJob -Name $BackupJobName | Set-VBRJobSchedule -Monthly -At "4:00" -NumberInMonth Last -Days Saturday
		Get-VBRJob -Name $BackupJobName | Enable-VBRJobSchedule
		Get-VBRJob -Name $BackupJobName | Disable-VBRJob
		
    }
	{($_ -eq "8")}
    {
        Clear
		Write-Host "`nCreating New Backup Job for Management VMs...`n"
		$BackupJobName = "$($ISEESiteID)_MGT_VMS"
		$PlainPassword = Read-Host -assecurestring "`nEnter the cryptic password for encryption (please remember this password, since this cannot be restored once it is lost) :"
		$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
		$Key = Add-VBREncryptionKey -Password $SecurePassword -Description "Veeam Administrator"
		$Entity = Find-VBRViEntity -VMsAndTemplates -name *vCenter*
		$repository = Get-VBRBackupRepository
		Add-VBRViBackupJob -Name $BackupJobName -Entity $Entity -BackupRepository $repository
		$job = Get-VBRJob -Name $BackupJobName
		$options = $job.GetOptions()
		$options.BackupStorageOptions.RetainCycles = 8
		Set-VBRJobOptions -Job $job -Options $options
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedStorageOptions -CompressionLevel 5 -EnableDeduplication $True -StorageBlockSize 7
		$Options=$job.getoptions()
		$Options.GenerationPolicy.RecheckScheduleKind = "Monthly"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayOfWeek = "Sunday"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayNumberInMonth = "Last"
		$Options.GenerationPolicy.EnableRechek = $true
		$job.SetOptions($Options) | out-null
		Set-VBRJobAdvancedStorageOptions -Job $job -EnableEncryption $true -EncryptionKey $Key
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $False -EnableFullBackup $True -FullBackupScheduleKind Monthly -DayNumberInMonth Last -DayOfWeek Saturday
		Get-VBRJob -Name $BackupJobName | Set-VBRJobSchedule -Monthly -At "4:00" -NumberInMonth Last -Days Saturday
		Get-VBRJob -Name $BackupJobName | Enable-VBRJobSchedule
		Get-VBRJob -Name $BackupJobName | Disable-VBRJob
		
		$Job = Get-VBRJob -name $BackupJobName
		$VMS = "*ISEEDC1*","*ISEEBDC2*","*THYDE1*"
		foreach ($VM in $VMS)
		{
		$Entity = Find-VBRViEntity -VMsAndTemplates -name $VM
		Add-VBRViJobObject -Job $Job -Entities $Entity
		}
		
    }
    {($_ -eq "9")}
    {
        Clear
		Write-Host "`nCreating New Backup Job for Deployment Node...`n"
		$BackupJobName = "$($ISEESiteID)_DeploymentNode"
		$PlainPassword = Read-Host -assecurestring "`nEnter the cryptic password for encryption (please remember this password, since this cannot be restored once it is lost) :"
		$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
		$Key = Add-VBREncryptionKey -Password $SecurePassword -Description "Veeam Administrator"
		$Entity = Find-VBRViEntity -VMsAndTemplates -name *DN1*
		$repository = Get-VBRBackupRepository
		Add-VBRViBackupJob -Name $BackupJobName -Entity $Entity -BackupRepository $repository
		$job = Get-VBRJob -Name $BackupJobName
		$options = $job.GetOptions()
		$options.BackupStorageOptions.RetainCycles = 8
		Set-VBRJobOptions -Job $job -Options $options
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedStorageOptions -CompressionLevel 5 -EnableDeduplication $True -StorageBlockSize 7
		$Options=$job.getoptions()
		$Options.GenerationPolicy.RecheckScheduleKind = "Monthly"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayOfWeek = "Sunday"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayNumberInMonth = "Last"
		$Options.GenerationPolicy.EnableRechek = $true
		$job.SetOptions($Options) | out-null
		Set-VBRJobAdvancedStorageOptions -Job $job -EnableEncryption $true -EncryptionKey $Key
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $False -EnableFullBackup $True -FullBackupScheduleKind Monthly -DayNumberInMonth Last -DayOfWeek Saturday
		Get-VBRJob -Name $BackupJobName | Set-VBRJobSchedule -Monthly -At "4:00" -NumberInMonth Last -Days Saturday
		Get-VBRJob -Name $BackupJobName | Enable-VBRJobSchedule
		Get-VBRJob -Name $BackupJobName | Disable-VBRJob
		
    }
   
}

}
---------------------------------------------------------**End of the script**----------------------------------------------
Thanks for your time.

Regards
leo
Egor Yakovlev
Veeam Software
Posts: 2536
Liked: 680 times
Joined: Jun 14, 2013 9:30 am
Full Name: Egor Yakovlev
Location: Prague, Czech Republic
Contact:

Re: Powershell script for configuration backup

Post by Egor Yakovlev »

Well if Get-VBRCommand returns nothing, means you don't have Veeam PowerShell up on your machine that executes that script.
Which VBR version you are running?

Also check what is returned by $Entity = Find-VBRViEntity -VMsAndTemplates -name *vCenter*.
Leo0601
Enthusiast
Posts: 39
Liked: 2 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: Powershell script for configuration backup

Post by Leo0601 »

Hi Egor,

Thanks for your response.

We are using Veeam backup and replication 10.

I have executed it ($Entity = Find-VBRViEntity -VMsAndTemplates -name *vCenter*).

Command ran successfully but I am not getting any output and also I am not getting any error. After that I have ran "$Entity". I am getting the same result (No error and No output) there as well.

Regards
leo
Egor Yakovlev
Veeam Software
Posts: 2536
Liked: 680 times
Joined: Jun 14, 2013 9:30 am
Full Name: Egor Yakovlev
Location: Prague, Czech Republic
Contact:

Re: Powershell script for configuration backup

Post by Egor Yakovlev » 1 person likes this post

"$Entity = Find-VBRViEntity -VMsAndTemplates -name *vCenter*" searches for machines with vCenter in them...it seems you don't have those in your environment? So it returns $null, and $Entity is $null, so next cmdlet to create a job for $null fails.

You can double check it in VBR console > Inventory > select added vCenter server > in search type "vCenter". That will list all machines with vCenter in name.
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Powershell script for configuration backup

Post by jhoughes » 1 person likes this post

Just before your error message, it will give you a line # and character #, along with the text of the line in your script that is causing the error. We need to know that to be able to assist with anything, as this is just basic PowerShell troubleshooting at this point.

Running the command that Egor provided and getting no output just means that you do not have a VM or template within your vSphere environment which contains 'vCenter' in the name.
Husband, Father, Solutions Architect, Geek Extraordinaire | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
Leo0601
Enthusiast
Posts: 39
Liked: 2 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: Powershell script for configuration backup

Post by Leo0601 »

Hi Egor & Jhoughes,

Thanks a lot.. Yes you both are right. Its searching for "vCenter" virtual machine in the vCenter. If its not there its not proceed futher.

Special thanks to "Egor" for checking this issue from the beginning and found the issue.

Actually this script has to create backup job for vCenter and other management servers as well (*ISEEDC1*","*ISEEBDC2*","*THYDE1*") as well when I am selecting number 8. This is the expectation.

But its failing in the first level itself hence vCenter VM is missing.

I need one last help from you experts, If the VCenter virtual machine is not present in the vCenter, It has to check for other management servers (*ISEEDC1*","*ISEEBDC2*","*THYDE1*") and It have to create backup job for other servers.

Can you please do me one last favour to change the logic. I have no idea how to change the logic.

I am looking forward to hear from you experts.

Thanks in advance.

Regards
Leo.
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Powershell script for configuration backup

Post by oleg.feoktistov » 1 person likes this post

Hi Leo,

If no -Server parameter passed to Find-VBRViEntity, it searches for the conditions you provided in all the relevant hosts you have as managed by VBR. For instance, if you have 2 vCenters and 1 standalone ESXi added to VBR console, Find-VBRViEntity -Name 'vCenter*' -VMsAndTemplates query will try to find the vm/template with such name in all of them. If the output is empty in this case, that means no vm was found across all the managed vCenters/ESXis.

Thanks,
Oleg
Leo0601
Enthusiast
Posts: 39
Liked: 2 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: Powershell script for configuration backup

Post by Leo0601 »

Hi Oleg,

Yes got it.

Thanks much for your time.

Regards
Leo
Leo0601
Enthusiast
Posts: 39
Liked: 2 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: Powershell script for configuration backup

Post by Leo0601 »

Hi Experts,

I am facing one more issue from my above script. I am getting the below error in last of the script.


--Cannot validate argument on parameter "Job" the argument is null provide a valid value for the argument and try running the command again-


Below I have posted that problematic block.
-----------------------------------------***************--------------------------------------------------------------
$Job = Get-VBRJob -name $BackupJobName
$VMS = "*ISEEDC1*","*ISEEBDC2*","*THYDE1*"
foreach ($VM in $VMS)
{
$Entity = Find-VBRViEntity -VMsAndTemplates -name $VM
Add-VBRViJobObject -Job $Job -Entities $Entity
}
----------------------------------------------*****************--------------------------------------------------------------

Thanks in advance.

Regards
Leo.
Egor Yakovlev
Veeam Software
Posts: 2536
Liked: 680 times
Joined: Jun 14, 2013 9:30 am
Full Name: Egor Yakovlev
Location: Prague, Czech Republic
Contact:

Re: Powershell script for configuration backup

Post by Egor Yakovlev »

Likewise, "$Job = Get-VBRJob -name $BackupJobName" returns $null.
Meaning you don't have a VBR job with name kept in $BackupJobName variable.
Leo0601
Enthusiast
Posts: 39
Liked: 2 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: Powershell script for configuration backup

Post by Leo0601 »

Hi Egor,

$BackupJobName variable is declared in the second line of this below script. So i am getting output when I execute only $BackupJobName.

Code: Select all

Write-Host "`nCreating New Backup Job for Management VMs...`n"
		$BackupJobName = "$($ISEESiteID)_MGT_VMS"
		$PlainPassword = Read-Host -assecurestring "`nEnter the cryptic password for encryption (please remember this password, since this cannot be restored once it is lost) :"
		$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
		$Key = Add-VBREncryptionKey -Password $SecurePassword -Description "Veeam Administrator"
		$Entity = Find-VBRViEntity -VMsAndTemplates -name *vCenter*
		$repository = Get-VBRBackupRepository
		Add-VBRViBackupJob -Name $BackupJobName -Entity $Entity -BackupRepository $repository
		$job = Get-VBRJob -Name $BackupJobName
		$options = $job.GetOptions()
		$options.BackupStorageOptions.RetainCycles = 8
		Set-VBRJobOptions -Job $job -Options $options
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedStorageOptions -CompressionLevel 5 -EnableDeduplication $True -StorageBlockSize 7
		$Options=$job.getoptions()
		$Options.GenerationPolicy.RecheckScheduleKind = "Monthly"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayOfWeek = "Sunday"
		$Options.GenerationPolicy.RecheckBackupMonthlyScheduleOptions.DayNumberInMonth = "Last"
		$Options.GenerationPolicy.EnableRechek = $true
		$job.SetOptions($Options) | out-null
		Set-VBRJobAdvancedStorageOptions -Job $job -EnableEncryption $true -EncryptionKey $Key
		Get-VBRJob -Name $BackupJobName | Set-VBRJobAdvancedBackupOptions -Algorithm Incremental -TransformFullToSyntethic $False -EnableFullBackup $True -FullBackupScheduleKind Monthly -DayNumberInMonth Last -DayOfWeek Saturday
		Get-VBRJob -Name $BackupJobName | Set-VBRJobSchedule -Monthly -At "4:00" -NumberInMonth Last -Days Saturday
		Get-VBRJob -Name $BackupJobName | Enable-VBRJobSchedule
		Get-VBRJob -Name $BackupJobName | Disable-VBRJob
		
		$Job = Get-VBRJob -name $BackupJobName
		$VMS = "*ISEEDC1*","*ISEEBDC2*","*THYDE1*"
		foreach ($VM in $VMS)
		{
		$Entity = Find-VBRViEntity -VMsAndTemplates -name $VM
		Add-VBRViJobObject -Job $Job -Entities $Entity
		}

Regards
Leo
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Powershell script for configuration backup

Post by oleg.feoktistov » 2 people like this post

Leo,

Please use </> option for wrapping your script in code tags when previewing a post so that it could be easier to read and copy the code you want to share. What Egor means is that Get-VBRJob couldn't find jobs with name "<$ISEESiteID_value>_MGT_VMS". It might be worth checking the job name and applying another condition/search pattern.

Thanks,
Oleg
Leo0601
Enthusiast
Posts: 39
Liked: 2 times
Joined: Oct 13, 2020 1:40 pm
Full Name: Leo
Contact:

Re: Powershell script for configuration backup

Post by Leo0601 »

Hi Oleg,

Noted. Let me check it once.

Thanks much for your suggestion regarding </> option for wrapping the script.

Regards
Leo
Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests