Restoring data from Power Shell script RRS feed

  • Question

  • I am hoping someone can help me with a PS script I am trying to create so we can automate the latest file backup restore to a destination.

    Very similar to this link, but instead I would like to restore a file from a disk to a different server.

    Still earning PowerShell so any help would be great. 


    # Set static variables
     $DPMServerName = "<DMP Server>"
     $SQLProtectionGroupName = "<SQL Protection Group>"
     $Database = "<database to restore>"
     $RestoreServerName = "<restore server name>"
     $RestorePath = "<restore location>"
    # Set restore to pull from dpm server with protection group
     $SQLProtectionGroup=Get-ProtectionGroup $DPMServerName | where-object { $_.FriendlyName -eq $SQLProtectionGroupName}
    #Set the datasource to pull from protection group and Database 
     $SQLDataSource = Get-DataSource -ProtectionGroup $SQLProtectionGroup | Where-object { $ -eq $database}
    #pull all express full recoverypoints from database
     $RecoveryPoints = Get-Recoverypoint $SQLDataSource | where-object { $_.HasFastRecoveryMarker -eq "Fast"}
    #Configure the Recovery Settings to pull from a SQL database and copy the files to the desired restore location
     $RecoveryOption = New-RecoveryOption -SQL -TargetServer $RestoreServerName -RecoveryLocation CopyToFolder -RecoveryType Restore -TargetLocation $RestorePath
    #Trigger the system to restore the latest Full-Express recovery point.
     $RestoreJob = Recover-RecoverableItem -RecoverableItem $RecoveryPoints[-1] -RecoveryOption $RecoveryOption
    Wednesday, September 28, 2016 5:14 PM