Configure NSX Manager backup using the API
If you are running NSX-V in a production environment it is crucial to have recent backups of NSX manager available. The NSX Manager backup settings can be configured either through […]
Audit and Consulting of Information Systems and Business Processes
If you are running NSX-V in a production environment it is crucial to have recent backups of NSX manager available. The NSX Manager backup settings can be configured either through […]
If you are running NSX-V in a production environment it is crucial to have recent backups of NSX manager available. The NSX Manager backup settings can be configured either through the webinterface or the RESTful API.
This is a short post about some gotchas I was running into while automating the backup configuration of NSX-V environments.
The NSX API documentation describes the following:
PUT https://<nsxmgr-ip>/api/1.0/appliance-management/backuprestore/backupsettings
Request Body:
<backupRestoreSettings> <ftpSettings> <transferProtocol></transferProtocol> <hostNameIPAddress></hostNameIPAddress> <port></port> <userName></userName><password></password> <backupDirectory></backupDirectory> <filenamePrefix></filenamePrefix> <passiveMode></passiveMode> <useEPRT></useEPRT> <useEPSV></useEPSV> </ftpSettings> <backupFrequency> <frequency></frequency> <dayOfWeek></dayOfWeek> <hourOfDay></hourOfDay> <minuteOfHour></minuteOfHour> </backupFrequency> <excludeTables> <excludeTable></excludeTable> <excludeTable></excludeTable> </excludeTables> </backupRestoreSettings>
The NSX API accepts the request. However, when an on-demand backup is requested through the NSX API the following error is returned.
POST https://<nsxmgr-ip>/api/1.0/appliance-management/backuprestore/backup
Status Code : 500 Internal Server Error
Response Body:
<?xml version="1.0" encoding="UTF-8"?> <errors><error><errorCode>100</errorCode></error></errors>
Here is the error when creating the backup through the UI:
Unfortunately the returned error is less descriptive, than the error returned during initiating an on-demand backup on an nsx manager with an empty backup configuration:
POST https://<nsxmgr-ip>/api/1.0/appliance-management/backuprestore/backup
Status Code: 400 Bad Request
Response Body:
<?xml version="1.0" encoding="UTF-8"?> <errors><error> <details>Invalid backup restore settings provided.</details> <errorCode>150512</errorCode><moduleName>vsm-appliance-mgmt</moduleName></error></errors>
When configuring the backup settings through NSX Manager webinterface you might notice the mandatory text box “Pass Phrase”
Somehow that parameter did not made it into the api guide nor in the parameter validation of the nsx api.
After adding the “passPhrase” parameter in the request body everything worked as expected.
Request Body:
<backupRestoreSettings> <ftpSettings> <transferProtocol></transferProtocol> <hostNameIPAddress></hostNameIPAddress> <port></port> <userName></userName> <password></password> <passPhrase></passPhrase> <backupDirectory></backupDirectory> <filenamePrefix></filenamePrefix> <passiveMode></passiveMode> <useEPRT></useEPRT> <useEPSV></useEPSV> </ftpSettings> <backupFrequency> <frequency></frequency> <dayOfWeek></dayOfWeek> <hourOfDay></hourOfDay> <minuteOfHour></minuteOfHour> </backupFrequency> <excludeTables> <excludeTable></excludeTable> <excludeTable></excludeTable> </excludeTables> </backupRestoreSettings>
This has been tested on NSX Version 6.1.3, 6.1.4 and 6.2