Skip to content

Latest commit

 

History

History
89 lines (80 loc) · 3.8 KB

02. Asset Restore FLR Powershell.md

File metadata and controls

89 lines (80 loc) · 3.8 KB

This Restores Files from CLI using FLR recoveries

Connect to PPDM API in AVS:

$connection=connect-PPDMapiEndpoint -trustCert -PPDM_API_BaseURI ppdmavs01.edub.csc
$RestoreFromHost = "WhqNQLqCLJ2yw.edub.csc"
$RestoreToHost_Name = "bM10k2Mjn53aO.edub.csc"

image

Get all linux Hosts with FLR Agent

We do this with Specifying a Filter

$linuxfilter = 'attributes.appHost.appServerTypes eq "FS" and not (lastDiscoveryStatus eq "DELETED") and details.appHost.os lk "linux" and details.appHost.phase eq "NONE"'
Get-PPDMhosts -filter $linuxfilter | ft

image

Read our Restore Host

$RestoreHostFilter = 'attributes.appHost.appServerTypes eq "FS" and not (lastDiscoveryStatus eq "DELETED") and details.appHost.os lk "linux" and details.appHost.phase eq "NONE"and hostname eq "' + $RestoreToHost_Name + '"'
$RestoreToHost = Get-PPDMhosts -filter $RestoreHostFilter
$RestoreToHost

image

Read the Asset to restore to identify the Asset Copies

$RestoreAssetFilter = 'type eq "FILE_SYSTEM" and protectionStatus eq "PROTECTED" and details.fileSystem.hostName eq  "' + $RestoreFromHost + '"'
$RestoreAssets = Get-PPDMAssets -Filter $RestoreAssetFilter
$RestoreAssets
$RestoreAssets | Get-PPDMcopy_map

image

Selecting and mounting the Asset Copy to Restore

write-host "Selecting Asset-copy for $RestoreFromHost"
$RestoreAssetCopy = $RestoreAssets | Get-PPDMassetcopies -filter 'state eq "IDLE"' | Select-Object -First 1
$RestoredCopy = New-PPDMRestored_copies -Copyobject $RestoreAssetCopy -Hostid $RestoreToHost.id -CustomDescription "Mount from Powershell"

do {
  Start-Sleep -Seconds 10    
  $MountedCopy = $RestoredCopy | Get-PPDMRestored_copies
}
until ($MountedCopy.status -eq "SUCCESS") 

image

Get the Base Browse list, e.g Mountroot Directory for FLR, wich is .basepath, as well ass the volumes, as .sources

$Parameters = @{
  HostID              = $RestoreToHost.id
  mountURL            = $MountedCopy.restoredCopiesDetails.targetFileSystemInfo.mountUrl
  BackupTransactionID = $RestoreAssetCopy.backupTransactionId
}
$BaseBrowselist = Get-PPDMFSAgentFLRBrowselist @Parameters
$BaseBrowselist

Browse the Volumes for Content, retrieving a Browselist .Path as the base for to restored Directories

$Parameters = @{
  HostID              = $RestoreToHost.id
  mountURL             = "$($BaseBrowselist.basePath)/$($Browselist.sources[0])"
  BackupTransactionID = $RestoreAssetCopy.backupTransactionId
}
$Browselist = Get-PPDMFSAgentFLRBrowselist @Parameters
$Browselist

image

Run the Restore

$Parameters = @{
  CopyObject           = $RestoreAssetCopy
  HostID               = $RestoreToHost.id 
  RestoreLocation      = "/tmp"
  RetainFolderHierachy = $true
  conflictStrategy     = "TO_ALTERNATE" 
  RestoreSources       = @("$($Browselist.path)/home/bottk", "$($Browselist.path)/root")
  CustomDescription    = "Restore from Powershell"
  Verbose              = $false
}

$Restore = Restore-PPDMFileFLR_copies @Parameters
$Restore | Get-PPDMactivities

image image