PowerShell script exchange
Post Reply
jmc
Service Provider
Posts: 103
Liked: 9 times
Joined: Sep 12, 2011 11:49 am
Full Name: jmc
Location: Duisburg - Germany
Contact:

backup immutable to date

Post by jmc » 1 person likes this post

hello all,

i have the problem that we have a lot of different backup jobs and backup copy jobs that additionally push data to the cloud. these S3 compatible object stores have an immutable flag set. since different repositories also have different retention times, it would be extremely helpful to create a list of the vm's and the remaining immutable time. unfortunately i couldn't find a usable cmdlet at veeam so far that gives me the information.

do any of you have an idea how this could be done?

thank's
jeff
"Who brakes late stays fast longer." - "Wer später bremst ist länger schnell"
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 669 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: backup immutable to date

Post by oleg.feoktistov » 1 person likes this post

Hi,

On backup level immutability flag is a property of a storage (e.g. vib, vbk). So to get immutability info on VM level you can start by querying storages of each backup and then sorting them as needed:

Code: Select all

$backups = Get-VBRBackup
foreach ($backup in $backups) {
  $storages = $backup.GetAllChildrenStorages()
  foreach ($storage in $storages) {
    $storage | select PartialPath, IsImmutable, ImmutableTillUtc
  }
}
GetAllChildrenStorages() method is unsupported, but there is no official way to obtain this data from created restore points.

Best regards,
Oleg
jmc
Service Provider
Posts: 103
Liked: 9 times
Joined: Sep 12, 2011 11:49 am
Full Name: jmc
Location: Duisburg - Germany
Contact:

Re: backup immutable to date

Post by jmc »

hi oleg,

thank's for the unsupported script. unfortunately it is not suitable here, because direct backups to the immutable are rarely saved. usually the targets are SOBR which use the cloud for capacity storage, or backup copy jobs. in both cases the script does not work. for backup copy jobs the method does not exist and bi SOBR it does not work.

thanks anyway
jeff
"Who brakes late stays fast longer." - "Wer später bremst ist länger schnell"
albertwt
Veteran
Posts: 936
Liked: 53 times
Joined: Nov 05, 2009 12:24 pm
Location: Sydney, NSW
Contact:

Re: backup immutable to date

Post by albertwt »

oleg.feoktistov wrote: Apr 17, 2023 10:07 pm Hi,

On backup level immutability flag is a property of a storage (e.g. vib, vbk). So to get immutability info on VM level you can start by querying storages of each backup and then sorting them as needed:

Code: Select all

$backups = Get-VBRBackup
foreach ($backup in $backups) {
  $storages = $backup.GetAllChildrenStorages()
  foreach ($storage in $storages) {
    $storage | select PartialPath, IsImmutable, ImmutableTillUtc
  }
}
GetAllChildrenStorages() method is unsupported, but there is no official way to obtain this data from created restore points.

Best regards,
Oleg
Hi @oleg.feoktistov,

I wonder if the method or function will be supported later on in the future.
--
/* Veeam software enthusiast user & supporter ! */
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 669 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: backup immutable to date

Post by oleg.feoktistov » 1 person likes this post

Hi,

The function to support it is noted, but cannot say that we have any short-term plans for it in powershell.
For backup copy job backups you might need to get child backups first:

Code: Select all

$backups = Get-VBRBackup -Name 'Backup Copy Job 1'
$childBackups = $backups.FindChildBackups()
$storages = $childBackups.GetAllChildrenStorages()
For backups residing on SOBR Capacity tier it should work out of the box unless you are using copy mode. Then you need to get shadow storages for the original ones from performance tier:

Code: Select all

$backups = Get-VBRBackup -Name 'Backup Copy Job 1'
$sobr = Get-VBRBackupRepository -ScaleOut -Name 'Scale-out Backup Repository 2'
$extent = Get-VBRCapacityExtent -Repository $sobr
 $totalStorages = @()
foreach ($backup in $backups) {
  $storages = $backup.GetAllChildrenStorages()
  foreach ($storage in $storages) {
    $shadowStorage = [Veeam.Backup.Core.CStorage]::GetShadowStorageByOriginalStorageId($storage.Id, $extent.Id)
    $totalStorages += $storage
    $totalStorages += $shadowStorage
    $storage | select PartialPath, IsImmutable, ImmutableTillUtc
    $shadowStorage | select PartialPath, IsImmutable, ImmutableTillUtc
   
  }
}
Let me know if it helps.

Best regards,
Oleg
jmc
Service Provider
Posts: 103
Liked: 9 times
Joined: Sep 12, 2011 11:49 am
Full Name: jmc
Location: Duisburg - Germany
Contact:

Re: backup immutable to date

Post by jmc »

hello oleg,

i'm so sorry, but it doesn't work. i have a simple scenario. one backup job called: DD_THA-ELK-Wasabi. the sobr is defined: Performance: DD-6300 & Capacity: Wasabi-ELK (S3-compatible with direct host) and named as: DD2200-Wasabi-ELK.

when i run the script than i get all VM's restore points. but i got only an immutable=false.

i defined:

$backups = Get-VBRBackup -Name 'DD_THA-ELK-Wasabi'
$sobr = Get-VBRBackupRepository -ScaleOut -Name 'DD2200-Wasabi-ELK'

i got no error but results like this:

PartialPath IsImmutable ImmutableTillUtc
----------- ----------- ----------------
ELK-EDS-Prod_BV1.vm-457137D2023-03-28T040022_F8CA.vib False
ELK-EDS-Prod_BV1.vm-457137D2023-03-28T040022_F8CA.vib False
ELK-EDS-Prod_BV1.vm-457137D2023-03-24T043054_9573.vbk False
ELK-EDS-Prod_BV1.vm-457137D2023-03-24T043054_9573.vbk False

the results are always double, and i think that one is the performance tier and the second the wasabi capacity tier. in the real i have up to 30 days immutability in capacity tier.

thx
jeff
"Who brakes late stays fast longer." - "Wer später bremst ist länger schnell"
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 669 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: backup immutable to date

Post by oleg.feoktistov »

Hi,

Looks like properties related to immutability don't get written properly in CStorage class anymore.
However, I found another method that seems to work in my v12 lab:

Code: Select all

$backup = Get-VBRBackup -Name 'Backup Job'
$childBackup = $backup.FindChildBackups()
$storages = $childBackup.GetAllChildrenStorages()

foreach ($storage in $storages) {
  $immutability = [Veeam.Backup.DBManager.CDBManager]::Instance.Storages.GetStoragesImmutability($storage.Id)
  $storage | select PartialPath, @{n='ImmutableTillUtc';e={$immutability.ImmutableUntilUtc}}
}
Best regards,
Oleg
jmc
Service Provider
Posts: 103
Liked: 9 times
Joined: Sep 12, 2011 11:49 am
Full Name: jmc
Location: Duisburg - Germany
Contact:

Re: backup immutable to date

Post by jmc »

hello oleg,

great job. i have change the script to get only the latest restore point, creation time and the time remaining:

Code: Select all

$backup = Get-VBRBackup -Name 'Backup-Job'
$childBackups = $backup.FindChildBackups()

foreach ($childBackup in $childBackups) {
    $latestStorage = $childBackup.GetAllChildrenStorages() | Sort-Object CreationTimeUtc -Descending | Select-Object -First 1
    $immutability = [Veeam.Backup.DBManager.CDBManager]::Instance.Storages.GetStoragesImmutability($latestStorage.Id)
    $remainingTime = $immutability.ImmutableUntilUtc - [DateTime]::UtcNow

    $latestStorage | select @{n='VMName';e={$childBackup.Name}}, 
                             @{n='CreationTimeUtc';e={$latestStorage.CreationTimeUtc}},
                             PartialPath,
                             @{n='ImmutableTillUtc';e={$immutability.ImmutableUntilUtc}},
                             @{n='TimeRemaining';e={$remainingTime}}
}
now the next important question: how can i get the results directly from the repository instead of the backup job?

background:
we have a whole series of job in object store like wasabi. but these have no backup job anymore and are located under (exported), (obsolete) or if a copy job exists under (copy).

more exactly e.g.: Object Storage (Copy) or Capacity Tier (Exported) or Object Storage (obsolete).

I want to delete these as soon as they are free (of course I delete the performance tier - if available).
is this also possible with the existing cmdlets?

thx
jeff
"Who brakes late stays fast longer." - "Wer später bremst ist länger schnell"
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 669 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: backup immutable to date

Post by oleg.feoktistov »

For capacity tier filtering storages by repository capacity tier should work:

Code: Select all

$repo = Get-VBRBackupRepository -ScaleOut -Name 'Scale-out Backup Repository'
$backups = Get-VBRBackup | where {$_.RepositoryId -eq $repo.Id}
$extent = Get-VBRCapacityExtent -Repository $repo
$totalStorages= @()
foreach ($backup in $backups) {
  $childBackups = $backup.FindChildBackups()
  $objectIds = $childBackups.GetObjectIds()
  foreach ($id in $objectIds) {
  $storages = $childBackups.GetStoragesInCapacityTier($id, $extent.Id)
  $totalStorages += $storages
  }
}
$totalStorages
For other cases that should do:

Code: Select all

$repo = Get-VBRBackupRepository -Name 'Repo'
$backups = Get-VBRBackup | where {$_.RepositoryId -eq $repo.Id}
$totalStorages = @()
foreach ($backup in $backups) {
  $childBackups = $backup.FindChildBackups()
  $storages = $childBackups.GetAllChildrenStorages()
  $totalStorages += $storages
  }
$totalStorages
P.S. That's just an example, I didn't add the immutability part.

Thanks!
jmc
Service Provider
Posts: 103
Liked: 9 times
Joined: Sep 12, 2011 11:49 am
Full Name: jmc
Location: Duisburg - Germany
Contact:

Re: backup immutable to date

Post by jmc »

hello oleg,

thank you for the editing. unfortunately we are going around in circles here. in your last post you come back to the scripts from before. i replied that the cmdlets probably don't work properly, because despite clear immutable time (backup copy direct to wasabi with immutable of 14 days) i only get as result that no immutable is set.

maybe the time there from the development will provide more specific cmdlets that directly checks the immutable time on the repositories and outputs.

thanks
for the effort.

mfg
jmc
"Who brakes late stays fast longer." - "Wer später bremst ist länger schnell"
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 669 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: backup immutable to date

Post by oleg.feoktistov »

Hello,

Please review the code from my last post and the comment about immutability part.
how can i get the results directly from the repository instead of the backup job?
This is exactly how you get results directly from the repository. We are not operating over jobs when working with Get-VBRBackup cmdlet. We filter backups by the repository they reside on and then get backups storages.
i replied that the cmdlets probably don't work properly, because despite clear immutable time (backup copy direct to wasabi with immutable of 14 days) i only get as result that no immutable is set.
Exactly, and I gave you examples on both scenarios separately - for getting immutable times for each storage and for getting storages copied to capacity tier. You just need to combine them.
maybe the time there from the development will provide more specific cmdlets that directly checks the immutable time on the repositories and outputs.
ImmutableTill is not the property of a repository, but of a single storage, so you will still need to get storages residing in the repository (via getting backups first).

Unfortunately, now there is no supported way to do that, but the best candidate for enhancement I would say is Get-VBRBackupFile cmdlet.

As for your scenario, I combined getting storages in capacity tier with obtaining their immutability time in one script below as another example:

Code: Select all

$repo = Get-VBRBackupRepository -ScaleOut -Name 'Scale-out Backup Repository 2'
$backups = Get-VBRBackup | where {$_.RepositoryId -eq $repo.Id}
$extent = Get-VBRCapacityExtent -Repository $repo
$totalStorages= @()
foreach ($backup in $backups) {
  $childBackups = $backup.FindChildBackups()
  $objectIds = $childBackups.GetObjectIds()
  foreach ($id in $objectIds) {
  $storages = $childBackups.GetStoragesInCapacityTier($id, $extent.Id)
  foreach ($storage in $storages) {
  $immutability = [Veeam.Backup.DBManager.CDBManager]::Instance.Storages.GetStoragesImmutability($storage.Id)
  $remainingTime = $immutability.ImmutableUntilUtc - [DateTime]::UtcNow

  $totalStorages += $storage | select @{n='VMName';e={$childBackup.Name}}, 
                             @{n='CreationTimeUtc';e={$storage.CreationTimeUtc}},
                             PartialPath,
                             @{n='ImmutableTillUtc';e={$immutability.ImmutableUntilUtc}},
                             @{n='TimeRemaining';e={$remainingTime}}
 
  }
  }
}
$totalStorages
Best regards,
Oleg
FAR
Lurker
Posts: 1
Liked: never
Joined: Jun 04, 2024 2:10 pm
Full Name: Fabian Röllnreiter
Contact:

Re: backup immutable to date

Post by FAR »

Hello,

I have successfully used Oleg's script several times, but I am getting the following error with a customer.
The only difference to other customers is that the performance tier is an SMB share on a NAS instead of a local partition. The capacity tier is a bucket from Wasabi.

Maybe someone has an idea what the problem is?


'Method invocation failed because [Veeam.Backup.Core.CBackup[]] does not contain a method
named 'GetObjectIds'.
At line:7 char:3
+ $objectIds = $childBackups.GetObjectIds()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound'

Thanks!
Fabian
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests