Skip to main content
Glama

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
NameRequiredDescriptionDefault
serverYesServer name
typeYesDatabase type
databaseYesDatabase name
outputFileYesOutput file path (will be created on remote server)
dbUserNoDatabase user
dbPasswordNoDatabase password
dbHostNoDatabase host (default: localhost)
dbPortNoDatabase port
compressNoCompress output with gzip (default: true)
tablesNoSpecific tables to dump (MySQL/PostgreSQL only)

Implementation Reference

  • 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' ],
  • 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; }
  • 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; }
  • 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; }
  • 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 }; /**

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bvisible/mcp-ssh-manager'

If you have feedback or need assistance with the MCP directory API, please join our Discord server