HOWTO: Clean up vRanger savepoints with Powershell

The scripts below I came up with as a way of identifying old or orphaned savepoints within vRanger 6.1.  Be careful with the remove command though as in its current form will also delete any differentials.  That’s probably what you’re looking for but if you have weird orphans, it might cause you some issues.  Pay close attention to what the reporting script says it’s going to delete.

#DELETE ALL VRANGER SAVE POINTS OLDER THAN 10 DAYS

# FIRST YOU NEED TO GET THE REPOSITORY ID FOR EACH REPOSITORY YOU WANT TO CHECK
Get-Repository | ft name, id

# TO SEE WHAT YOU'RE GOING TO DELETE, RUN THE FOLLOWING
get-repository -id [repositoryidfoundabove] | Get-RepositorySavepoint | Where-Object {$_.StartTime -le [datetime]::Today.AddDays(-10)} | select VMPath, EndTime, SizeInmbStored, SpaceSavingTechTypeID | convertto-csv -NoTypeInformation | clip.exe

# THE SCRIPT BELOW WILL REMOVE ALL SAVEPOINTS OLD THAN 10 DAYS 
# *IMPORTANT* THIS WILL DELETE BOTH FULL AND DIFFERENTIAL SAVEPOINTS
$savepoints = get-repository -id [repositoryidfoundabove] | Get-RepositorySavepoint | Where-Object {$_.StartTime -le [datetime]::Today.AddDays(-10)
foreach ($savepoint in $savepoints){
remove-savepoint -SavePointsToRemove $savepoint
}


Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.