Introducing SOC Insights for BloxOne Threat Defense: Boost your SOC efficiency with AI-driven insights to eliminate manual work and accelerate investigation and response times. Read the blog announcement here.

API & Integration, DevOps,NetOps,SecOps

Reply

RestoreDatabase

New Member
Posts: 4
795     0

I've been reading through documentation and all the posts here related to restoring the database, but I'm coming up short.  The backup via the API works great, I just can't restore from the backup.  Looking for any help that can point me in the right direction.

 

I'm using powershell here, but I tried using curl and ran into the same issues.  Here are the steps I'm performing:

1) (WORKS) Login, get a cookie.  The cookie is used throughout the next calls.

2) (WORKS) Register for the file upload, get a URL and token.

3) (NO CLUE IF IT WORKS) Upload the backup file (nothing returned).  Because of all that is involved, I'm trying to use PS v5.1.  Below is the latest iteration of my attempt to upload the file.  It takes the amount of time that I would feel it would to upload the file, but I have no idea how to verify it worked.  Response that is returned is successful

$fieldName = "filedata"
$BackupFilePath = "c:\test\database.bak"
$FileUploadUrl = "https://<INFOBLOX_ADDR>/http_direct_file_io/req_id-UPLOAD-0315315435135/import_file"

try 
{
    Add-Type -AssemblyName 'System.Net.Http'

    $ClientMessageHandler = New-Object System.Net.Http.HttpClientHandler
    $ClientMessageHandler.CookieContainer = $Session.Cookies
    $Client = [System.Net.Http.HttpClient]::new($ClientMessageHandler)
    $content = New-Object System.Net.Http.MultipartFormDataContent
    $fileStream = [System.IO.File]::OpenRead($BackupFilePath)
    $fileName = [System.IO.Path]::GetFileName($BackupFilePath)
    $fileContent = New-Object System.Net.Http.StreamContent($fileStream)
    $content.Add($fileContent, $fieldName, $fileName)
            
    $response = $client.PostAsync($FileUploadUrl, $content).Result
    $response.EnsureSuccessStatusCode()
}
catch 
{
    Write-Error $_
    exit 1
}
finally
{
    if ($null -ne $client) { $client.Dispose() }
    if ($null -ne $content) { $content.Dispose() }
    if ($null -ne $fileStream) { $fileStream.Dispose() }
    if ($null -ne $fileContent) { $fileContent.Dispose() }
}

4) (DOES NOT WORK) Run the restore function, passing the token from the 2nd step above.  When I run this, it immediately returns a 400 : The remote server returned an error.

$infoblox_uri = "https://<infoblox_addr>/wapi/v2.12/fileop?_function=restoredatabase"

$data = @{
            keep_grid_ip = 'True'
            mode = 'FORCED'
            token = <TOKEN_FROM_STEP_2>
        }


$response = Invoke-RestMethod -Uri $infoblox_uri -ContentType "application/json" -Method Post -Body ($data | ConvertTo-Json) -WebSession $Session

I've turned up debugging, which was mentioned in another thread, but I don't see anything in there that sticks out to me as an issue. 

 

Any help would be much appreciated! Thank you!!! 

Re: RestoreDatabase

New Member
Posts: 4
796     0

Case sensitivity bites me again. 

 

I manually put an all upper case FORCED into my sample code here, but the actual variable that was feeding the api call in my code was not.  Smiley Sad

Showing results for 
Search instead for 
Did you mean: 

Recommended for You

Businesses are investing heavily into securing company resources from cyber-attacks form cybercrimin