ssh_db_dump
Dump MySQL, PostgreSQL, or MongoDB databases to files on remote servers through SSH connections. Specify database type, name, and output path to create backups.
Instructions
Dump database to file (MySQL, PostgreSQL, MongoDB)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| server | Yes | Server name | |
| type | Yes | Database type | |
| database | Yes | Database name | |
| outputFile | Yes | Output file path (will be created on remote server) | |
| dbUser | No | Database user | |
| dbPassword | No | Database password | |
| dbHost | No | Database host (default: localhost) | |
| dbPort | No | Database port | |
| compress | No | Compress output with gzip (default: true) | |
| tables | No | Specific tables to dump (MySQL/PostgreSQL only) |
Implementation Reference
- src/tool-registry.js:49-54 (registration)Registration of the ssh_db_dump tool as part of the database tool group in the TOOL_GROUPS export.database: [ 'ssh_db_dump', 'ssh_db_import', 'ssh_db_list', 'ssh_db_query' ],
- src/database-manager.js:23-56 (helper)Helper function to build MySQL database dump command, core logic for ssh_db_dump when type=mysql.export function buildMySQLDumpCommand(options) { const { database, user, password, host = 'localhost', port = 3306, outputFile, compress = true, tables = null } = options; let command = 'mysqldump'; if (user) command += ` -u${user}`; if (password) command += ` -p'${password}'`; if (host) command += ` -h ${host}`; if (port) command += ` -P ${port}`; command += ' --single-transaction --routines --triggers'; command += ` ${database}`; if (tables && Array.isArray(tables)) { command += ` ${tables.join(' ')}`; } if (compress) { command += ` | gzip > "${outputFile}"`; } else { command += ` > "${outputFile}"`; } return command; }
- src/database-manager.js:61-99 (helper)Helper function to build PostgreSQL database dump command, core logic for ssh_db_dump when type=postgresql.export function buildPostgreSQLDumpCommand(options) { const { database, user, password, host = 'localhost', port = 5432, outputFile, compress = true, tables = null } = options; let command = ''; if (password) { command = `PGPASSWORD='${password}' `; } command += 'pg_dump'; if (user) command += ` -U ${user}`; if (host) command += ` -h ${host}`; if (port) command += ` -p ${port}`; command += ' --format=custom --clean --if-exists'; if (tables && Array.isArray(tables)) { for (const table of tables) { command += ` -t ${table}`; } } command += ` ${database}`; if (compress) { command += ` | gzip > "${outputFile}"`; } else { command += ` > "${outputFile}"`; } return command; }
- src/database-manager.js:104-137 (helper)Helper function to build MongoDB database dump command, core logic for ssh_db_dump when type=mongodb.export function buildMongoDBDumpCommand(options) { const { database, user, password, host = 'localhost', port = 27017, outputDir, compress = true, collections = null } = options; let command = 'mongodump'; if (host) command += ` --host ${host}`; if (port) command += ` --port ${port}`; if (user) command += ` --username ${user}`; if (password) command += ` --password '${password}'`; if (database) command += ` --db ${database}`; if (collections && Array.isArray(collections)) { for (const collection of collections) { command += ` --collection ${collection}`; } } command += ` --out "${outputDir}"`; if (compress) { command += ` && tar -czf "${outputDir}.tar.gz" -C "$(dirname ${outputDir})" "$(basename ${outputDir})"`; command += ` && rm -rf "${outputDir}"`; } return command; }
- src/database-manager.js:7-20 (helper)Constants for supported database types and default ports used by ssh_db_dump tool.export const DB_TYPES = { MYSQL: 'mysql', POSTGRESQL: 'postgresql', MONGODB: 'mongodb' }; // Default ports export const DB_PORTS = { mysql: 3306, postgresql: 5432, mongodb: 27017 }; /**