04-05-2023 08:25 PM
can anyone let us know why we API call catalog/images get back image id of client seems from replication, not local master backup, how we get local master server image id of backup client?
Solved! Go to Solution.
04-20-2023 12:27 AM
A complete curl command for the above filter looks like this:
curl -k -X 'GET' 'https://master/netbackup/catalog/images?filter=clientName%20eq%20%27myclient%27%20and%20backupTime%20ge%202023-04-01T10:00:00.000Z%20and%20backupTime%20le%202023-04-20T00:00:00.000Z' -H 'accept: application/vnd.netbackup+json;version=9.0' -H 'Authorization: <auth string>'
05-08-2023 02:24 PM
Hi @uncleAIroh
I've not used this API so do not know if it will do as you want. Anyway, it seems to have been added in 10.1. You can go here for the available API calls for all NBU versions. The link starts you at 10.1, but other versions can be selected.
https://sort.veritas.com/public/documents/nbu/10.1/windowsandunix/productguides/html/hostproperties/
David
04-18-2023 12:48 PM
is there any way to get previous backup image id from API call catalog/images? we only get back image id in last 24 hours, even with query params = { 'sortBy': 'backupTime', 'sortOrder': 'asc', 'showAllVersions': 'true' }, stll back current version
04-18-2023 04:48 PM
Hi @uncleAIroh
I imagine you are not correctly specifying the filter to your call. Can you please share the call you are makeing so we can see why it may not be correct. I assume what you are seeing would be the equivalent of running bpimagelist without any time arguements which returns the past 24 hours only, while what you are after is the image list from some time range in the past.
Thanks
David
04-19-2023 08:36 PM
code as following;
# provide client asset id
mfiler="( clientName eq "asset_id")"
params = { ' filter':mfilter, 'sortBy': 'backupTime', 'sortOrder': 'desc', 'showAllVersions': 'true' }
# Set the API headers
headers = { 'Authorization': 'Bearer token', 'Content-Type': 'application/json' }
# Send the API request
response = requests.get(api_url, filter=mfilter params=params, headers=headers)
we only get back latest backup image id with this code
04-19-2023 10:33 PM
Hi @uncleAIroh
Where is the backupTime specification in the filter? The API call will return only inmages in the last 24 hours without specifying the time range in the filter (mfilter).
David
04-20-2023 12:02 AM
The filter should look something like this:
filter=clientName eq 'asset_id' and backupTime ge 2023-04-01T10:00:00.000Z and backupTime le 2023-04-20T00:00:00.000Z
This would show all backup images from April 1 until now for the client asset_id.
04-20-2023 12:27 AM
A complete curl command for the above filter looks like this:
curl -k -X 'GET' 'https://master/netbackup/catalog/images?filter=clientName%20eq%20%27myclient%27%20and%20backupTime%20ge%202023-04-01T10:00:00.000Z%20and%20backupTime%20le%202023-04-20T00:00:00.000Z' -H 'accept: application/vnd.netbackup+json;version=9.0' -H 'Authorization: <auth string>'
04-20-2023 09:15 AM
it works thanks!
how can I get API work catalog/size, which like we run "bpdbjobs -cleanup -force"? the goal is get catalog space usage..
04-20-2023 03:52 PM
Hi @uncleAIroh
What information are you trying to obtain - and I don't understand the command you mentioned (it's not a valid option on any version I know)?
What do you mean by catalog space usage? Are you referring to the protected size of backups for a client (i.e. the sum of all the backups held for a particular client)?
Cheers
David
04-24-2023 07:32 PM
Tanks for your responding, we want to use API call to find master server catalog DB size, how much allocated, how many white space in catalog DB can be cleanup ( or defrag) when was last successful backup
04-24-2023 07:52 PM
which version NetBackup has API endpoint /admin/catalog/size and /admin/storage/servers or never have?
04-24-2023 08:11 PM
can we enable endpoint by modifying webapi.conf? such as /command/bpimagelist and so on
04-24-2023 10:27 PM
Hi @uncleAIroh
@uncleAIroh wrote:
we want to use API call to find master server catalog DB size, how much allocated, how many white space in catalog DB can be cleanup ( or defrag) when was last successful backup
There is no direct API for this. The best you could do for successful DB backup is to use the jobs to check for the last catalog backup. The rest wouldn't really make sense to create an API for.
@uncleAIroh wrote:
which version NetBackup has API endpoint /admin/catalog/size and /admin/storage/servers or never have?
Storage server API's have been available for a whjile now (at least since v 9). There is no API for catalog size.
@uncleAIroh wrote:
can we enable endpoint by modifying webapi.conf? such as /command/bpimagelist and so on
I can't see this as being something that Veritas would support or condone if even possible.
Cheers
David
05-01-2023 08:23 PM
we tried to add backup host to master by API with endpoint /config/hosts, post payload as
add_host_payload = { "data": { "attributes": { "hostName": host_name, "osType": "WINDOWS" # or "UNIX" }, "type": "host" } }
host_name="newclient"
we always get message: {'errorCode': 8708, 'errorMessage': 'Constraint violations are detected for the given attributes in the input request.', 'attributeErrors': {}, 'fileUploadErrors': [], 'errorDetails': ['Constraint violations are detected for the given attributes in the input request: hostName ']}
we change different name, we got same result how we fix this issue
05-01-2023 08:52 PM
Hi @uncleAIroh
The error indicates you have not sent the API request in the correct form/format. One thing the client host name should be referenced as "hostName" - beyond that.... without the actual API call you made, it is very difficult to help.
David
05-02-2023 07:04 AM
requests.post(add_host_url, header=headers json=add_host_payload)
add_host_url = https://{nb_server}:{nb_port}/netbackup/config/hosts
headers= {"Current-Type": "CLIENT", "Authentication": jwt}
05-02-2023 03:42 PM
Hi @uncleAIroh
Given the command appears to be the equivalent of the CLI "nbemcmd -addhost" I think you will need to add more paramters into your data body than you have shown.
Also not sure why the "Current-Type": "CLIENT" is included - I do not see any requirement for this and to me it appeaars that this also could be cuasing some problems.
Finally - there is not header paramter shown for "Content-Type" which again would cause problems.
I would suggest using the api-docs section to try your calls manually before looking to program them (https://<master>/api-docs) or use a program such as postman to get the calls working first.
David
05-03-2023 08:01 PM
sorry typo following is query we used;
payload = {'data': {'attributes': {'hostName': 'hostname, 'osType': 'UNIX'}, 'type': 'host'}}
headers = {'Content-Type': 'application/json', 'Authorization': jwt};
following is code;
host_name = a
os_type = "attributes": {
"hostName": "host_name",
"osType": "UNIX"
#"nbuHostType":"CLIENT"
},
"type": "host"
}
}
add_host_response = requests.post(url, headers=headers, json=add_host_payload, verify=False)
is this hosts only mean for media server or include backup client? if we need to add backup clients, do we need to add host to master first?
we test another way add client to policy as following
headers = {'Content-Type': 'application/json', 'Authorization': ': jwt}
url = "https://master/netbackup/config/policies/policyname/clients"
add_host_payload = {'clientName': 'servername, 'osType': 'UNIX'}
got follwoing error message; get command without issue, when we use put got following error message
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:877)
requests.put(url, headers=headers, json=add_host_payload, verify=False)
05-03-2023 11:34 PM
Hi @uncleAIroh
Firstly I do not believe it would be necessary to add a client to the EMM database before adding to a policy (this is not something you would normally do).
What I would suggest you do is to use the Chrome F12 function to examine the payload being sent by the WebUI for and equivalent function (such as adding a new client to a policy). This should give the information and data required for this API call. You can also use the API documentation available from the master server to try out the various API calls.
SSL errors to me point to a problem with the way you made the API call, rather than the contents of the call.
I do note that you continue to show the Content-Type incorrectly - if you review the documentation is indicates that the required format is: "Content-Type: application/vnd.netbackup+json;version=6.0"
- the number at the end varying depending on the NetBackup version.
Thanks
David
05-04-2023 08:37 AM
we following your recommendation for webGUI can api add host to Master thanks !!
but when we try to add host to policy endpoint
url = "https://master/netbackup/config/policies/policyname/clients/clientname"
Swagger provide payload as following;
what is type and id we have put in?
{
"data": {
"type": "string",
"id": "string",
"attributes": {
"availabilityGroup": "string",
"cluster": "string",
"databaseName": "string",
"dbid": "string",
"dbUniqueName": "string",
"groupID": "string",
"instanceName": "string",
"OS": "string",
"hardware": "string",
"nasVendor": "string"
}
}
}