PowerShell script exchange
Post Reply
sandinetcom
Enthusiast
Posts: 29
Liked: 1 time
Joined: Oct 01, 2019 6:04 am
Full Name: Sandip Saha
Contact:

need to retention check for my all policy

Post by sandinetcom »

Hello,

please help me how to get my backup copy job retention for my all policy

I have Long-Term Retention Policy (GFS) for my backup copy job policy some policy are 4 weeks some policies are 12 months

I need to know in every month my all policy retention time

anyone please help me for any api and powershell script

Thank
Sandip Saha
Mildur
Product Manager
Posts: 9848
Liked: 2607 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: need to retention check for my all policy

Post by Mildur » 3 people like this post

You can try that :-) I have build the script in the last 15 minutes. It's functional, but not really optimized.

Code: Select all

# Getting all Backup Copy Jobs
$jobs = Get-VBRJob | Where-Object {($_.Jobtype -eq "BackupSync") -or ($_.Jobtype -eq "SimpleBackupCopyPolicy") }

# Loop through each Job to get the neccessary Information
$BackupCopyGFSSettings = $NULL

ForEach ($job in $Jobs) {
  $options = Get-VBRJobOptions -Job $job
  $tempObject = 
        [PSCustomObject]@{
            JobName = $job.Name
            WeeklyGFSEnabled = $options.GfsPolicy.Weekly.IsEnabled
            WeeklyGFSRetention = $options.GfsPolicy.Weekly.KeepBackupsForNumberOfWeeks
            WeeklyGFSDesiredTime = $options.GfsPolicy.Weekly.DesiredTime
            MonthlyGFSEnabled = $options.GfsPolicy.Monthly.IsEnabled
            MonthlyGFSRetention = $options.GfsPolicy.Monthly.KeepBackupsForNumberOfMonths
            MonthlyGFSDesiredTime = $options.GfsPolicy.Monthly.DesiredTime
            YearlyGFSEnabled = $options.GfsPolicy.Yearly.IsEnabled
            YearlyGFSRetention = $options.GfsPolicy.Yearly.KeepBackupsForNumberOfYears
            YearlyGFSDesiredTime = $options.GfsPolicy.Yearly.DesiredTime
        }
        $BackupCopyGFSSettings = [Array]$BackupCopyGFSSettings + $tempObject
}

$BackupCopyGFSSettings | ft
Product Management Analyst @ Veeam Software
sandinetcom
Enthusiast
Posts: 29
Liked: 1 time
Joined: Oct 01, 2019 6:04 am
Full Name: Sandip Saha
Contact:

Re: need to retention check for my all policy

Post by sandinetcom » 1 person likes this post

Hello Mildur,

thanks for your time and help
I will check and update you

Thank again
Mildur
Product Manager
Posts: 9848
Liked: 2607 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: need to retention check for my all policy

Post by Mildur »

Hi Sandip
Your welcome.
Product Management Analyst @ Veeam Software
sandinetcom
Enthusiast
Posts: 29
Liked: 1 time
Joined: Oct 01, 2019 6:04 am
Full Name: Sandip Saha
Contact:

Re: need to retention check for my all policy

Post by sandinetcom »

Hello Mildur,

Thanks for your support
ones again I need help in my environment PS is disable only enable windows powershell ISE (x86)
in this shell I am not able to access get-vbrbackup

Code: Select all

PS C:\Windows\system32> Get-Module -ListAvailable Veeam*


    Directory: C:\Program Files\Veeam\Backup and Replication\Console


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   1.0        Veeam.Backup.PowerShell


    Directory: C:\Program Files\Veeam\Backup and Replication\Explorers\Exchange


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   2.0        Veeam.Exchange.PowerShell


    Directory: C:\Program Files\Veeam\Backup and Replication\Explorers\SharePoint


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   2.0        Veeam.SharePoint.PowerShell


    Directory: C:\Program Files\Veeam\Backup and Replication\Explorers\SQL


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   1.0        Veeam.SQL.PowerShell


    Directory: C:\Program Files\Veeam\Backup and Replication\Explorers\ActiveDirectory


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   1.0        Veeam.ActiveDirectory.PowerShell


    Directory: C:\Program Files\Veeam\Backup and Replication\Explorers\Oracle


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   1.0        Veeam.Oracle.PowerShell


    Directory: C:\Program Files\Veeam\Backup and Replication\Explorers\Teams


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   2.0        Veeam.Teams.PowerShell


PS C:\Windows\system32> get-vbrbackup
get-vbrbackup : The term 'get-vbrbackup' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
At line:1 char:1
+ get-vbrbackup
+ ~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (get-vbrbackup:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Windows\system32>
can anyone please help me how to enable veeam shell

Thanks
Sandip Saha
Mildur
Product Manager
Posts: 9848
Liked: 2607 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: need to retention check for my all policy

Post by Mildur »

Please use the 64bit Powershell ISE environment.
It does work with Windows Powershell ISE, but not with Windows Powershell ISE (x86).
Product Management Analyst @ Veeam Software
sandinetcom
Enthusiast
Posts: 29
Liked: 1 time
Joined: Oct 01, 2019 6:04 am
Full Name: Sandip Saha
Contact:

Re: need to retention check for my all policy

Post by sandinetcom »

Dear Mildur,

Thanks for your time and support
Iam run your script and get below output

PS D:\> .\test.ps1
WARNING: This cmdlet is no longer supported for computer backup jobs. Use "Get-VBRComputerBackupJob" instead.

JobName WeeklyGFSEnabled WeeklyGFSRetention WeeklyGFSDesiredTime MonthlyGFSEnabled MonthlyGFSRetention MonthlyGFSDesiredTime YearlyGFSEnabled Yearl
yGFSR
etent
ion
------- ---------------- ------------------ -------------------- ----------------- ------------------- --------------------- ---------------- -----
MYSQL_10.10.10.10_DR Copy True 4 Sunday True 120 First False 1
MSSQL_10.1.00.00_DR Copy True 4 Sunday True 120 First False 10
Oracle_veeamrhelbkp_AML_LOS_DR_Copy True 4 Sunday True 120 First False


can you please help with completed date for weekly backup and monthly backup like below

Backup Copy Policy Weekly available backup Monthly available backup

mssql_10.1.00.00_DR Copy 8/22/2021 8/18/2021
Mildur
Product Manager
Posts: 9848
Liked: 2607 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: need to retention check for my all policy

Post by Mildur »

Do you want to have a list with all GFS Restore Points or only when the latest weekly or monthly restore point was taken?
How many Jobs do you have? Only the three Copy jobs?
Product Management Analyst @ Veeam Software
sandinetcom
Enthusiast
Posts: 29
Liked: 1 time
Joined: Oct 01, 2019 6:04 am
Full Name: Sandip Saha
Contact:

Re: need to retention check for my all policy

Post by sandinetcom »

Hello Midur,

Thanks for your time and help
sorry for late replay

I need to take data all my GFS restore point details with all my all copy job

I have 72 copy jobs

details need like below

Code: Select all

policy name                        weekly                              monthly 
mssql_10.1.00.00_DR Copy          8/29/2021                        8/1/2021
                                                 8/22/2021                        9/5/2021
                                                  9/5/2021
                                                 9/12/2021
Thanks for your help

Thanks
Sandip Saha
soncscy
Veteran
Posts: 643
Liked: 312 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey
Contact:

Re: need to retention check for my all policy

Post by soncscy »

Hi Sandip,

If your goal is getting data on restore points and their corresponding backups, then use Get-VBRRestorePoint:

https://helpcenter.veeam.com/docs/backu ... ml?ver=110

Fabian's script has a way of getting all the Backup Copy Jobs; you'll then loop over those jobs and use Get-VBRBackup with -Name matching on the $Job.Name property. You can use the .GetBackup() method (I believe it's that) to avoid the extra cmdlet but if you're not familiar with powershell, use the cmdlet instead.

Once you have the backup object from Get-VBRBackup you can get the restore points, and that will print your list of restore points, including GFS data.

Try it in the shell and just play with it a bit, and then pick and choose what you want from the list, or make a custom object with

$SomeObject = [PSCustomObject]@{
Property1 = "thing1"
Property2 = "thing2"
...
}

It's not going to be sensible to build a tool for you I think, so instead, this is what you need to get the information for your report. Play with it a bit and see what you find.
sandinetcom
Enthusiast
Posts: 29
Liked: 1 time
Joined: Oct 01, 2019 6:04 am
Full Name: Sandip Saha
Contact:

Re: need to retention check for my all policy

Post by sandinetcom »

Hello,

Thanks For help

can you help me please one line code for my one policy so i am check same commend one by one.
I am new in powershell please help me

Thanks
Sandip Saha
Mildur
Product Manager
Posts: 9848
Liked: 2607 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: need to retention check for my all policy

Post by Mildur »

I will do it later.
Product Management Analyst @ Veeam Software
sandinetcom
Enthusiast
Posts: 29
Liked: 1 time
Joined: Oct 01, 2019 6:04 am
Full Name: Sandip Saha
Contact:

Re: need to retention check for my all policy

Post by sandinetcom »

Hello,

any one please help me on this please


Thanks
Sandip Saha
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: need to retention check for my all policy

Post by oleg.feoktistov »

Hi Sandip,

The easiest way to differentiate restore points with GFS flags are by their storages. Example:

Code: Select all

$backup = Get-VBRBackup -Name 'Backup Name'
$rps = Get-VBRRestorePoint -Backup $backup
foreach ($rp in $rps) {
  $storage = $rp.GetStorage()
  $storage | select @{n='Name';e={$rp.Name}}, GfsPeriod, CreationTime
}
Then you can filter GFS ones by GfsPeriod, find their creation times and combine this information with job/policy name eventually transforming it into any report you like.

Best regards,
Oleg
sandinetcom
Enthusiast
Posts: 29
Liked: 1 time
Joined: Oct 01, 2019 6:04 am
Full Name: Sandip Saha
Contact:

Re: need to retention check for my all policy

Post by sandinetcom »

Hello Oleg,

thanks for your time and help
I am run this PowerShell commend but no output is show.

can you please help me

Code: Select all

PS C:\Users\srvbackup\Desktop> $backup = Get-VBRBackup -Name 'MDM DB_Cluster_DR Copy'
$rps = Get-VBRRestorePoint -Backup $backup
foreach ($rp in $rps) {
  $storage = $rp.GetStorage()
  $storage | select @{n='Name';e={$rp.Name}}, GfsPeriod, CreationTime
}

PS C:\Users\srvbackup\Desktop>
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: need to retention check for my all policy

Post by oleg.feoktistov »

Do you happen to query backup made with backup copy job in immediate mode?
If you do, you need to get child backups first:

Code: Select all

$backup = Get-VBRBackup -Name 'MDM DB_Cluster_DR Copy'
$childBackups = $backup.FindChildBackups()
$rps = Get-VBRRestorePoint -Backup $childBackups[0]
Thanks!
sandinetcom
Enthusiast
Posts: 29
Liked: 1 time
Joined: Oct 01, 2019 6:04 am
Full Name: Sandip Saha
Contact:

Re: need to retention check for my all policy

Post by sandinetcom »

Hello,

Thanks For your time I am sorry I am still not get details Please help

Code: Select all

PS C:\Windows\system32> $backup = Get-VBRBackup -Name 'MDM DB_Cluster_DR Copy'
PS C:\Windows\system32> $childBackups = $backup.FindChildBackups()
PS C:\Windows\system32> $rps = Get-VBRRestorePoint -Backup $childBackups[0]
PS C:\Windows\system32> foreach ($rp in $rps) {
>>   $storage = $rp.GetStorage()
>>   $storage | select @{n='Name';e={$rp.Name}}, GfsPeriod, CreationTime
>> }
PS C:\Windows\system32>
in my environment our all copy job have gfs policy for monthly and weekly I need only below format


Code: Select all

policy name                        weekly                              monthly 
mssql_10.1.00.00_DR Copy          8/29/2021                        8/1/2021
                                                 8/22/2021                        9/5/2021
                                                  9/5/2021
                                                 9/12/2021

Please support me

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

Re: need to retention check for my all policy

Post by oleg.feoktistov »

Sandip,

I'd suggest you to perform a very basic debugging: start with figuring out if any of your variables return null values. Given that there is no error thrown, I'd say it's the method causing this issue. Cmdlets do return null exceptions if anything of null value is passed.

Thanks,
Oleg
sandinetcom
Enthusiast
Posts: 29
Liked: 1 time
Joined: Oct 01, 2019 6:04 am
Full Name: Sandip Saha
Contact:

Re: need to retention check for my all policy

Post by sandinetcom »

Oleg,

sorry for this I am new in PowerShell with veeam
Can you please help me in one policy for me.

thanks for time and help

Thanks
Sandip
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: need to retention check for my all policy

Post by oleg.feoktistov »

Sandip,

I understand, but it's not about Veeam powershell module.
It's about very common troubleshooting steps you would try with any script, cmdlet, object etc.
This forum doesn't teach powershell, it provides help with meanings, design and structure of VBR PS module entities.
I have given you all the necessary steps to get the script running, now it is the matter of general powershell knowledge.
If you are completely new to powershell, I would rather start with this documentation.

Thanks,
Oleg
sandinetcom
Enthusiast
Posts: 29
Liked: 1 time
Joined: Oct 01, 2019 6:04 am
Full Name: Sandip Saha
Contact:

Re: need to retention check for my all policy

Post by sandinetcom »

Oleg,

Thanks for your time and support.

I am understand but
as in our environment all copy job policy heaving weekly and monthly GFS policy I am try Get-VBRBackup and Get-VBRRestorePoint but I am not getting any output for GFS details

I need help for only one policy getting how many weekly and monthly GFS restore point details.
in gui >> go to >>> diskcopy>> right click on policy >>> properties>>> its showing all restore point details

Please help how to get this details in PowerShell.


Thanks
Sandip Saha
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: need to retention check for my all policy

Post by oleg.feoktistov »

Did you try to follow those basic troubleshooting steps I wrote above? Thanks!
sandinetcom
Enthusiast
Posts: 29
Liked: 1 time
Joined: Oct 01, 2019 6:04 am
Full Name: Sandip Saha
Contact:

Re: need to retention check for my all policy

Post by sandinetcom »

hello Oleg,

Thanks for your help

sorry for my query
I need only how to collect my weekly and monthly GFS restore point details for one copy job.

please help the PowerShell commend

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

Re: need to retention check for my all policy

Post by oleg.feoktistov »

Sandip, I think we are going around in circles here. I did help you with the working script, which I tested in my environment. Apparently, there is something else about your case or this query that causes null values somewhere in the script and eventually gives no output. However, I cannot help you further if I don't know where are these null values coming from. Since I don't see the same behaviour in my lab, I asked you for basic troubleshooting on your side. I cannot do such troubleshooting for you, I can only suggest steps for it.
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests