PowerShell script exchange
Post Reply
scottmr
Influencer
Posts: 14
Liked: never
Joined: Apr 13, 2016 12:27 pm
Full Name: Scott R
Contact:

Powershell Add Repository Name to VBRRestorpoint

Post by scottmr »

I'm running this-would like the Repository name (not path) to it. Possible?

Get-VBRRestorePoint -Name *ServerName* | Out-File d:\report\servername.csv
scottmr
Influencer
Posts: 14
Liked: never
Joined: Apr 13, 2016 12:27 pm
Full Name: Scott R
Contact:

Re: Powershell Add Repository Name to VBRRestorpoint

Post by scottmr »

To clarify,

I'd like to see where all my restore points for a particular server are as I have a bit many respositories.
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Powershell Add Repository Name to VBRRestorpoint

Post by david.domask »

Hi @scottmr

I wrote a function a long time back that I modified for you that might help. You can edit the Select statements or the $StoragePathsAndBlocksize line to add/remove elements you want in the report.

Code: Select all

function Get-StoragesPathsAndBlocksizeFromBackup {
	param(
		[Parameter(Mandatory=$true, Position=0)]
		[Object[]]$Backup
	)
	$Storages = $Backup[0].GetallChildrenStorages() | Sort-Object -Property PartialPath, CreationTime -Descending
	$Repository = $Backup.FindRepository()[0]
	$StoragePathsandBlocksize  = @()
	if($Repository.Type -eq "ExtendableRepository"){
		foreach($Storage in $Storages){
			$Extent = $Repository.GetRepositoryForExistingStorage($Storage.Id)
			if($Backup.JobID -eq '00000000-0000-0000-0000-000000000000'){
				$JobName = $Backup.GetMetaFilePath().Elements[0]
			}Else{
				$jobName = $Backup.FindJob().Name
			}
			$StoragePathsandBlocksize += New-Object -TypeName psobject -Property @{Repository=$Extent.Name;Extent=$Extent.Name;Path=$($Extent.Path.ToString(),$JobName.ToString(),$Storage.filepath -join "\");BlockSize=$Storage.BlockAlignmentSize;CreationTime=$Storage.CreationTime}
			}
	} else {
		$StoragePathsandBlocksize += $Storages | Sort-Object -Property  PartialPath, CreationTime -Descending | Select-Object -Property @{n="Repository";e={$Repository.Name}}, PartialPath,BlockAlignmentSize
	}
	return $StoragePathsandBlocksize
}
This is for v12 and later, but should work. YOu will get a backup with Get-VBRBackup and save it to some variable (e.g., $backup), then load that function and run:

Get-StoragesPathsAndBlocksizeFromBackup -Backup $backup

This will work for both backups on Scale-out Backup Repositories and standalone repositories.

Example output for simple repository:

Code: Select all

PS C:\Users\Administrator> $backup = Get-VBRBackup -name 'vmware-direct-*'
PS C:\Users\Administrator> Get-StoragesPathsAndBlocksizeFromBackup -Backup $backup[0]

Repository   PartialPath                                              BlockAlignmentSize
----------   -----------                                              ------------------
bb-non-immut DDom-TinyVM_replica.vm-9330D2023-02-01T220019_3161.vib                 4096
bb-non-immut DDom-TinyVM_replica.vm-9330D2023-02-01T140351_028A.vbk                 4096
bb-non-immut ddom-tinyvm_replica.vm-230661D2024-03-14T220017_BF49.vib               4096
bb-non-immut ddom-tinyvm_replica.vm-230661D2024-03-13T220015_3697.vib               4096
bb-non-immut ddom-tinyvm_replica.vm-230661D2024-03-12T220001_08A9.vib               4096
bb-non-immut ddom-tinyvm_replica.vm-230661D2024-03-11T220022_5DAD.vib               4096
bb-non-immut ddom-tinyvm_replica.vm-230661D2024-03-10T220009_86DF.vib               4096
bb-non-immut ddom-tinyvm_replica.vm-230661D2024-03-09T220000_0C4C.vib               4096
bb-non-immut ddom-tinyvm_replica.vm-230661D2024-03-08T220008_0DBE.vbk               4096
bb-non-immut ddom-tinyvm.vm-148644D2024-03-14T220017_4C38.vib                       4096
bb-non-immut ddom-tinyvm.vm-148644D2024-03-13T220015_C7B5.vib                       4096
bb-non-immut ddom-tinyvm.vm-148644D2024-03-12T220001_F183.vib                       4096
bb-non-immut ddom-tinyvm.vm-148644D2024-03-11T220022_B450.vib                       4096
bb-non-immut ddom-tinyvm.vm-148644D2024-03-10T220009_1743.vib                       4096
bb-non-immut ddom-tinyvm.vm-148644D2024-03-09T220000_A3FD.vib                       4096
bb-non-immut ddom-tinyvm.vm-148644D2024-03-08T220008_163D.vbk                       4096
David Domask | Product Management: Principal Analyst
scottmr
Influencer
Posts: 14
Liked: never
Joined: Apr 13, 2016 12:27 pm
Full Name: Scott R
Contact:

Re: Powershell Add Repository Name to VBRRestorpoint

Post by scottmr »

Thank you for the reply, but I can't get either to work.

for this one

Looks like I run Get-VBRBackup first with my backup name for the variable.
$backup = Get-VBRBackup -name 'backupserver1-*'

What about this one? Looks like I should be able to run it right after the one above?
Get-StoragesPathsAndBlocksizeFromBackup -Backup $backup[0]
scottmr
Influencer
Posts: 14
Liked: never
Joined: Apr 13, 2016 12:27 pm
Full Name: Scott R
Contact:

Re: Powershell Add Repository Name to VBRRestorpoint

Post by scottmr »

BTW I'm on V12
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Powershell Add Repository Name to VBRRestorpoint

Post by david.domask »

Hi @scottmr,

First, I would just check that the $backup variable only has one entry; in my example I used a wild-card for short-hand to avoid extra typing, but in your case it might have returned multiple backups. Try with the exact name.

So you will do:

1. Copy and paste the function into your shell -- you will need to include the function in your scripts moving forward as basically it's a custom function I wrote for this.
2. Once the function is loaded, get a single backup with Get-VBRBackup and save it to $backup
3. Then run Get-StoragesPathsAndBlocksizeFromBackup -Backup $backup

If there are errors, please post the text here so we can comment.
David Domask | Product Management: Principal Analyst
scottmr
Influencer
Posts: 14
Liked: never
Joined: Apr 13, 2016 12:27 pm
Full Name: Scott R
Contact:

Re: Powershell Add Repository Name to VBRRestorpoint

Post by scottmr »

Thank you David. I'm not great at using variables in PS. I'm going to take a little time to read up on using them then try again. I'd like to gain more understanding of them.

I really appreciate you taking the time to answer. I'll report back.
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests