Advertisement
PureGremlin

Find orphaned restore points

Oct 23rd, 2024
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## source https://forums.veeam.com/veeam-backup-replication-f2/vib-files-are-left-behind-t72166.html
  2. ## build list of all restorepoints in Veeam DB
  3. $vbrrp = Get-VBRRestorePoint
  4. ## query storage backing of RPs
  5. $vbrrpstorage = $vbrrp.findstorage()
  6.  
  7. ##manually list out repo filesystem items
  8. $root = "\\UNCpath\f$\"
  9. $drive = "F"
  10. $volume = "$($drive):\"
  11.  
  12. New-PSDrive -Root $root -PSProvider FileSystem -Name $drive -Credential $cred
  13. $repofiles=gci $volume -File -Recurse -Include @('*.temp','*.vbk','*.vib')
  14. remove-psdrive $drive
  15.  
  16. ##Compare file system to db RPs.
  17. $badfiles=$repofiles|?{$vbrrpstorage.PartialPath.elements -NotContains $_.name}
  18.  
  19. ## use clipboard to transfer file info to repo
  20. $badfiles| select name,fullname,directoryname|ConvertTo-Csv | clip
  21.  
  22. ## on repo build file list
  23. $badfiles= Get-Clipboard |ConvertFrom-Csv
  24.  
  25. ## instead of immediately hard deleting files, move to a temp directory
  26. ## create map file to replace UNC path with local drive
  27. $map=@()
  28. $badfiles | %{$map +=New-Object PSObject -Property @{
  29.  source = $_.fullname.replace($root,$volume)
  30.  destination = $_.fullname.replace($root+"ARCHIVE",$volume+"badfiles")
  31.  dir = $_.directoryname.replace($root+"ARCHIVE",$volume+"badfiles")
  32.  }
  33.  }
  34. ## create sub dirs and move files out of Repo path
  35. $map|% {if (!(test-path $_.dir)){New-Item -ItemType Directory -Path $_.dir }
  36.  Move-Item -Path $_.source -Destination $_.destination}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement