opnsense_sys_backup_download
Download OPNsense configuration backup as XML. Retrieve current running config or a specific backup by ID.
Instructions
Download an OPNsense configuration backup as XML. Downloads the current running config if no backup_id is specified.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| backup_id | No | Specific backup ID to download (e.g. 'config-1773423430.7934.xml'). Omit to download the current running config. |
Implementation Reference
- src/tools/system.ts:138-145 (handler)Handler case for 'opnsense_sys_backup_download' that parses args with BackupDownloadSchema, builds the API path (with optional backup_id), calls client.getRaw() to download XML, and returns the result.
case "opnsense_sys_backup_download": { const parsed = BackupDownloadSchema.parse(args); const backupPath = parsed.backup_id ? `/core/backup/download/this/${encodeURIComponent(parsed.backup_id)}` : "/core/backup/download/this"; const xml = await client.getRaw(backupPath); return { content: [{ type: "text", text: xml }] }; } - src/tools/system.ts:18-23 (schema)BackupDownloadSchema validates that backup_id is an optional string. If omitted, the current running config is downloaded.
const BackupDownloadSchema = z.object({ backup_id: z .string() .optional() .describe("Specific backup ID to download. If omitted, downloads the current running config."), }); - src/tools/system.ts:54-68 (registration)Tool definition for 'opnsense_sys_backup_download' registered in systemToolDefinitions array with description and inputSchema showing backup_id as optional string.
{ name: "opnsense_sys_backup_download", description: "Download an OPNsense configuration backup as XML. Downloads the current running config if no backup_id is specified.", inputSchema: { type: "object" as const, properties: { backup_id: { type: "string", description: "Specific backup ID to download (e.g. 'config-1773423430.7934.xml'). Omit to download the current running config.", }, }, }, }, - src/index.ts:64-64 (registration)Registration of the handler function (handleSystemTool) for all system tool definitions, including opnsense_sys_backup_download, in the central toolHandlers map.
for (const def of systemToolDefinitions) toolHandlers.set(def.name, handleSystemTool); - src/client/opnsense-client.ts:37-47 (helper)The getRaw() method used by the handler to fetch an XML response from the OPNsense API, used for downloading the backup as raw text.
async getRaw(path: string): Promise<string> { try { const response = await this.http.get<string>(path, { responseType: "text", headers: { Accept: "application/xml" }, }); return response.data; } catch (error: unknown) { throw extractError(error, `GET ${path} (raw)`); } }