Configure backup REST API
A Backup REST API is an interface that allows you to programmatically manage backup operations using standard HTTP requests. These APIs enable automation and control of the backup process across different systems and services.
You can use the Portworx Backup backup REST API to create, delete, schedule, restore backups and other operation tasks. This API is organized around REST and returns responses in JSON format.
To configure backup rest APIs, you need to expose Swagger UI and then fetch an access token for the instance.
Expose Swagger UI
To expose Swagger UI in Portworx Backup:
-
Expose
px-backup
deployment as REST interface:$ kubectl expose deployment -n px-backup px-backup --type=NodePort --port=10001 --name px-backup-rest
Output:
service/px-backup-rest exposed
-
Check if the service is properly created:
$ kubectl get service -n px-backup | grep rest
Output:
px-backup-rest NodePort <node_IP> <none> 10001:<node_port>/TCP 25s
-
Open the swagger UI endpoint
http://(NodeIP:NodePort)/swagger-ui/
in your web browser to access the API through swagger:
Fetch an access token
To fetch the token for an instance, login with the admin credentials and then perform the following steps:
-
Fetch access token with the same admin credentials used for login:
curl --data 'grant_type=password&client_id=pxcentral&username=admin&password=password' http://<IP>:<Port>/auth/realms/master/protocol/openid-connect/token --silent | jq -r ".access_token"
-
Add the token:
-
Click Authorize on the Swagger UI page.
-
Add the token generated with the
Bearer
prefix and a space in between. -
Click Authorize on Available authorizations.
-
Click Close.
-