PowerShell script exchange
Post Reply
Aschtra
Novice
Posts: 3
Liked: never
Joined: Aug 08, 2018 8:46 am
Contact:

Count the amount of restore point to keep per job

Post by Aschtra »

Hello,

I am currently trying to create a powershell script that shows the amount of restore point per VM per Job. I tried creating some things but I am unable to complete it.

$job = "jobname"
$vm = "vmname"
$count = $(get-vbrbackup -name $job | Get-VBRRestorePoint -Name $vm | Measure-Object).Count
write-host $count

But that only shows it it for 1 vm for an explicit job. I googled alot and the closest thing I could find on what we want is the following script

Get-VBRRestorePoint | Select Name, @{N="Job Name";E={$_.FindSourceJob().name}} | Group Name,"Job Name" | Sort Name > test2.txt

Which outputs the following:

Code: Select all

Count Name                      Group                                                                                                                        
----- ----                      -----                                                                                                                        
    7 server1                   {@{Name=server1; Job Name=job1}, @{Name=server1; Job Name=CO...
    1 server1                   {@{Name=server1; Job Name=job2}}                                                           
    7 server1                   {@{Name=server1; Job Name=job3}, @{Name=server1; Job Name=TAP...
   14 server1                  {@{Name=server1; Job Name=job4}, @{Name=server1; Job Nam...
I think the output is wrong because the script might be for a different version of Veeam. We are using Veeam 9.5
The colums 'group' must only contain the jobname. Anyone has an idea on how to do this?
veremin
Product Manager
Posts: 20284
Liked: 2258 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Count the amount of restore point to keep per job

Post by veremin »

Isn't this script something you're looking for? Thanks.
Aschtra
Novice
Posts: 3
Liked: never
Joined: Aug 08, 2018 8:46 am
Contact:

Re: Count the amount of restore point to keep per job

Post by Aschtra »

Hello,

Sorry for late reply. No, I've seen that script and it was not what I am looking for.
I opened a case at veeam and got 2 scripts that we'd like to use:

Code: Select all

Get-VBRRestorePoint | Select Name, @{N="Job Name";E={$_.FindSourceJob().name}} | Group name, "Job Name" -NoElement | sort Name | format-list -Property count, name
Which gives us the amount of restore points, per VM per Job. Which has an output like:

Code: Select all

Count : 7
Name  : *servername*, *jobname*
and:

Code: Select all

Get-VBRJob | ForEach-Object {$JobName = $_.Name; if ($_.JobType -eq "BackupSync") {$_.GetOptions().options.rootnode.generationpolicy | select @{N="JobName";E={$JobName}},SimpleRetentionRestorePoints,GFSRecentPoints,GFSWeeklyBackups,GFSMonthlyBackups,GFSQuarterlyBackups,GFSYearlyBackups} elseif ($_.JobType -eq "Backup") {$_.GetOptions().options.rootnode | select @{N="JobName";E={$JobName}},RetainCycles}}
Which gives us the configured amount of restore points in the job. Which has an output for backup jobs like:

Code: Select all

JobName      : *jobname*
RetainCycles : 7
And an output for copy jobs like:

Code: Select all

JobName                      : *Jobname*
SimpleRetentionRestorePoints : 7
GFSRecentPoints              : 7
GFSWeeklyBackups             : 4
GFSMonthlyBackups            : 0
GFSQuarterlyBackups          : 0
GFSYearlyBackups             : 0
ThierryF
Expert
Posts: 129
Liked: 33 times
Joined: Mar 31, 2018 10:20 am
Contact:

Re: Count the amount of restore point to keep per job

Post by ThierryF »

What about

$RPS=Get-VBRRestorePoint | where {((Get-Date) - ($_.CreationTime)).totaldays -le "10"} ;
foreach ($jobobj in get-VBRBackupSession | where {((Get-Date) - ($_.CreationTime)).totaldays -le "10"} | sort-object -property Creationtime -Descending ) {
foreach ($TS in $jobobj.GetTaskSessions()) {
$TSNAME=$TS.name ;
$count=0;
foreach ($RP in $RPS | where {$_.name -eq $TSNAME} ) {$count=$count+1;}
write-host "Job ", $jobobj.Name , " VM ", "$TSNAME" , " RP " , $count ,"`n";
}
}

Output :
Job XXXJOBNAMEXXXXX VM XXXXVMNAMEXXX RP 20

PS : Remove or adjust "| where {((Get-Date) - ($_.CreationTime)).totaldays -le "10"} " if you want to query
on a defined time range. This sample is for last 10 days.

HTH

TH
Rambarransingh.N
Influencer
Posts: 16
Liked: never
Joined: Aug 15, 2018 10:40 pm
Contact:

Re: Count the amount of restore point to keep per job

Post by Rambarransingh.N »

On this note, i havea script where i pass in the vm i want to backup. The script works fine for about 12 vm's. However one of them produces restore points - lots of them. No other vm does this.

Complete at a loss to explain. I am trying to figure out how to delete them. As a matter a fact, i would like, actually, have already tried deleting the zip in the hopes of getting rid of the rstr pnts - no joy.

Any ideas?

Thnx,
Nikita :?
ThierryF
Expert
Posts: 129
Liked: 33 times
Joined: Mar 31, 2018 10:20 am
Contact:

Re: Count the amount of restore point to keep per job

Post by ThierryF »

Did you have a look at this one ?
https://helpcenter.veeam.com/docs/backu ... tml?ver=95

HTH

TH
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests