backup_database
Create a backup of the PocketBase database by specifying a backup name, ensuring data safety and recovery readiness for advanced database operations.
Instructions
Create a backup of the PocketBase database
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | backup name |
Implementation Reference
- src/index.ts:962-984 (handler)The main handler function for the 'backup_database' tool. It authenticates as a PocketBase admin user and creates a database backup using the PocketBase SDK's backups.create method, returning the result as text content.private async backupDatabase(args: any) { try { // Authenticate with PocketBase await this.pb.collection("_superusers").authWithPassword(process.env.POCKETBASE_ADMIN_EMAIL ?? '', process.env.POCKETBASE_ADMIN_PASSWORD ?? ''); // Create a new backup const backupResult = await this.pb.backups.create(args.name ?? '', {}); return { content: [ { type: 'text', text: JSON.stringify(backupResult, null, 2), }, ], }; } catch (error: unknown) { throw new McpError( ErrorCode.InternalError, `Failed to backup database: ${pocketbaseErrorMessage(error)}` ); } }
- src/index.ts:598-606 (schema)Input schema definition for the 'backup_database' tool, specifying an optional 'name' property of type string.inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'backup name', }, }, },
- src/index.ts:595-607 (registration)Registration of the 'backup_database' tool in the server's tools list, passed to setTools, including name, description, and input schema.{ name: 'backup_database', description: 'Create a backup of the PocketBase database', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'backup name', }, }, }, },
- src/index.ts:689-690 (registration)Switch case in the CallToolRequestHandler that dispatches 'backup_database' tool calls to the backupDatabase handler method.case 'backup_database': return await this.backupDatabase(request.params.arguments);