Infoblox’s global team of threat hunters uncovers a DNS operation with the ability to bypass traditional security measures and control the Great Firewall of China. Read about “Muddling Meerkat” and the many other threat actors discovered by Infoblox Threat Intel here.

API & Integration, DevOps,NetOps,SecOps


API call to retrieve Backup DB

New Member
Posts: 2
866     1

Hi all and thanks in advance for any replies.


First time poster, long time subscriber.


Anyway, I am trying to retrieve the Backup DB .csv via api but keep getting the below error

C:\Users\e157716\PycharmProjects\SunchProdAndDev\venv\lib\site-packages\urllib3\ InsecureRequestWarning: Unverified HTTPS request is being made to host ''. Adding certificate verification is strongly advised. See:
Error creating a database backup: 400

Process finished with exit code 0

My code is as follows:

import requests

# Infoblox API information
infoblox_url = 'xxx' # Adjust the URL and version as needed
infoblox_user = 'yyy'
infoblox_password = 'zzz'

# Function to create an Infoblox database backup
def create_database_backup():
endpoint = '/grm/backup'
url = infoblox_url + endpoint

# Prepare a request to create a database backup
data = {
"comment": "Database backup created via API" # Optional comment

response =, auth=(infoblox_user, infoblox_password), json=data, verify=False) # Disable SSL verification; use it with caution

if response.status_code == 200:
response_data = response.json()
backup_url = response_data['url']

# You can download the backup file if needed
# backup_response = requests.get(backup_url, auth=(infoblox_user, infoblox_password), verify=False)
# Handle the downloaded backup file as required
print("Database backup created successfully.")
print(f"Error creating a database backup: {response.status_code}")

if __name__ == "__main__":

We are running: 8.6.3-51135-1241097029df

Re: API call to retrieve Backup DB

Posts: 306
866     1

Looks like your grid is using self-signed certificates. That's not a problem but you will need to set up a requests session, and supply some parameters to bypass SSL certificate validation.


Here's a quick example of setting up a session, and getting the current WAPI version

global SESSION
SESSION = requests.session()
get_version = f'https://{gm}/wapi/v1.0/?_schema'
json_headers = {'content-type': 'application/json'}

resp = SESSION.get(get_version, headers=json_headers,

json_data = json.loads(resp.text)

# Save the authentication cookie for use in subsequent requests.
ibapauth_cookie = resp.cookies['ibapauth']

# Use the ibapauth cookie to authenticate instead of userid/password.
global COOKIE
COOKIE = {'ibapauth': ibapauth_cookie}

# Get supported versions
versions = json_data["supported_versions"]
versions.sort(key=lambda s: list(map(int, s.split('.'))))  # Sort Versions

# Get the latest version
global WAPI
WAPI = versions[-1]"Using wapi version %s", WAPI)"Capturing supported objects for version %s", WAPI)

You will need to generate the backup file first, using the fileop function.


Here's an example with curl. 

# Download Grid Backup

# Request grid backup generation

curl -k -u admin:infoblox -X POST ''

    "token": "eJytjj0LwjAURf9KyWyTvrSExq1SBUFaEMExpE2swX6ZRlDE/24z6Ori+M7lnnefSN9HYx/CmU6j\nZQCMp8CiNKaYA0toxBcButl2jtDZuXFaEgKcYmApBkyJZ0IZq2snTqbVwgzE6qswKszLY7ErszyE\niCYwq2LKIWFRTJR0spKTxpW8oNnvb6H7elCmb/yn1bb48m5QfhjKs0Mm9uvNJ/CMTG6wstHEdeN/\nphjlvb9q6PUGzdpb/w==\n", 
    "url": ""

# Download file from URL

curl -k -u admin:infoblox -H "Content-type:application/force-download" -O ''
# And then close the file using the token
curl -k1 -u admin:infoblox -X POST '' \
-H "Content-Type: application/json" -d \
  "token": "eJytjj0LwjAURf9KyWyTvrSExq1SBUFaEMExpE2swX6ZRlDE/24z6Ori+M7lnnefSN9HYx/CmU6j\nZQCMp8CiNKaYA0toxBcButl2jtDZuXFaEgKcYmApBkyJZ0IZq2snTqbVwgzE6qswKszLY7ErszyE\niCYwq2LKIWFRTJR0spKTxpW8oNnvb6H7elCmb/yn1bb48m5QfhjKs0Mm9uvNJ/CMTG6wstHEdeN/\nphjlvb9q6PUGzdpb/w==\n"



Re: API call to retrieve Backup DB

New Member
Posts: 2
866     1
Wow, thanks for the quick reply.

Could I have an example with Pythin?

[Image result for Southwest Airlines heart clipart]


This e-mail message and all attachments transmitted with it may contain legally privileged and confidential information intended solely for the use of the addressee. If the reader of this message is not the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately and delete this message from your system. Thank you.

Re: API call to retrieve Backup DB

New Member
Posts: 5
866     1

This works - could add session stuff:


This script downloads an Infoblox database backup and saves it to the local file system.
It connects to an Infoblox Grid Manager using the RESTful API and authenticates using
the provided credentials. The backup file is downloaded using the URL received from
the response of initiating the backup session. The file is then saved locally with a
timestamped filename. Finally, a POST request is sent to trigger the download complete
using the received token.


import requests
import json
import time

# Disable SSL warnings

# Infoblox Grid variables
gm_hostname = ""
gm_url = f"https://{gm_hostname}/wapi/v2.11"
gm_user = "admin"
gm_password = "your-pwd"
now = time.strftime("%Y-%m-%d")
outputfile = f"infoblox_backup_{now}.bak"
headers = {"content-type": "application/json"}

# Function to create an Infoblox database backup
def create_infoblox_backup():
"""Function to download Infoblox database backup"""

# Prepare a request to create a database backup
# print('\n' + gm_url + '/fileop?_function=getgriddata' + '\n')
payload = {"type": "BACKUP"}
data = {"comment": "Database backup created via API"} # Optional comment

print("Initiating the backup on server ...\n")
response =
auth=(gm_user, gm_password),

if response.status_code == 200:
print("Creation of the backup file was successful ...\n")
response_dict = response.json()
backup_url = response_dict["url"]
backup_token = response_dict["token"]
print("backup URL: ", backup_url + "\n")
print(backup_token + "\n")

# Step 2: You can download the backup file if needed using the url
print( "Initiating download of backup file from URL provided in API response ...\n" )
download_headers = {"content-type": "application/force-download"}
download_response = requests.get(
auth=(gm_user, gm_password),
open(outputfile, "wb").write(download_response.content)

print("Telling Infoblox download is complete, start cleanup ...\n")
close_response =
auth=(gm_user, gm_password),

print("Database backup created and downloaded successfully.\n")

print(f"Error creating a database backup: {response.status_code}")

if __name__ == "__main__":
Showing results for 
Search instead for 
Did you mean: 

Recommended for You