backup_database
Create a backup of your PocketBase database to protect data and enable recovery. Specify a backup name to organize and identify your database snapshots.
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 handler function that executes the backup_database tool. It authenticates as admin using environment variables and calls PocketBase's backups.create with the provided name (default empty) and empty options, 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 object with 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 tools list provided to the MCP server for ListTools requests.
{ 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)Dispatch case in the CallTool request handler that routes calls to the backupDatabase method.
case 'backup_database': return await this.backupDatabase(request.params.arguments);