Skip to main content
Hello,I'm taking the opportunity right now to work on a like disaster recovery plan like, with Veeam.Once the replica job is up and running, my goal is to be able to trigger a failover if the server's ping is knocked out, so I wrote a little homemade powershell script to do that. If it is useful take it.^^

 

Clear-Host
Function FailoverCheck{
    $server = "SERVER NAME"

    if (Test-Connection $server -Count 1 -Quiet -ErrorAction SilentlyContinue){
        Write-Output "$server connected successfully."
    }else{
        Write-Output "Connection to $server failed."
        Write-Verbose "Pause for 10 minutes...then try again" -Verbose
        Start-Sleep -Seconds 5 # set to 600
        if (Test-Connection $server -Count 1 -Quiet -ErrorAction SilentlyContinue){
            Write-Output "$server connected successfully after 2nd try."
        }else{
            Write-Verbose "Failed again. $server needs restart." -Verbose
            # Insert Command to restart application here.
            $RestorePoint = Get-VBRReplica | Get-VBRRestorePoint -Name $server | Sort-Object $_.creationtime -Descending | Select -First 1
            Start-VBRHvReplicaFailover -RestorePoint $RestorePoint
            return 10
        }
    }
}

while ($true){
    FailoverCheck
    Write-Verbose "Script done. Pause for 5 minutes...then restart script." -Verbose
    Start-Sleep -Seconds 5 # set to 300
}

 

Any scripts are useful when it comes to Veeam.  Thanks for sharing. 👍🏼


Comment