Count the amount of restore point to keep per job

PowerShell script exchange

Count the amount of restore point to keep per job

Veeam Logoby Aschtra » Wed Aug 08, 2018 10:15 am

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?
Aschtra
Lurker
 
Posts: 2
Liked: never
Joined: Wed Aug 08, 2018 8:46 am

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

Veeam Logoby v.Eremin » Fri Aug 10, 2018 6:33 pm

Isn't this script something you're looking for? Thanks.
v.Eremin
Veeam Software
 
Posts: 14966
Liked: 1122 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

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

Veeam Logoby Aschtra » Thu Aug 16, 2018 11:46 am

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
Aschtra
Lurker
 
Posts: 2
Liked: never
Joined: Wed Aug 08, 2018 8:46 am

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

Veeam Logoby ThierryF » Thu Aug 16, 2018 12:12 pm

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
ThierryF
Influencer
 
Posts: 24
Liked: 4 times
Joined: Sat Mar 31, 2018 10:20 am

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

Veeam Logoby Rambarransingh.N » Sat Aug 18, 2018 3:35 pm

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 :?
Rambarransingh.N
Novice
 
Posts: 3
Liked: never
Joined: Wed Aug 15, 2018 10:40 pm

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

Veeam Logoby ThierryF » Mon Aug 20, 2018 6:07 am

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

HTH

TH
ThierryF
Influencer
 
Posts: 24
Liked: 4 times
Joined: Sat Mar 31, 2018 10:20 am


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 8 guests