Skip to main content
Glama
bvisible

MCP SSH Manager

ssh_backup_restore

Restore server backups via SSH to recover databases or files using specified backup IDs and connection parameters.

Instructions

Restore from a backup on remote server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serverYesServer name
backupIdYesBackup ID to restore
databaseNoTarget database name (for db restores)
dbUserNoDatabase user
dbPasswordNoDatabase password
dbHostNoDatabase host (default: localhost)
dbPortNoDatabase port
targetPathNoTarget path for files restore (default: /)
backupDirNoBackup directory (default: /var/backups/ssh-manager)

Implementation Reference

  • Registration of the 'ssh_backup_restore' tool in the 'backup' tool group in the central tool registry used for configuration and validation.
    // Backup group (4 tools) - Backup and restore operations
    backup: [
      'ssh_backup_create',
      'ssh_backup_list',
      'ssh_backup_restore',
      'ssh_backup_schedule'
    ],
  • Core helper functions for building restore commands for different backup types (MySQL, PostgreSQL, MongoDB, files). These functions generate the shell commands executed remotely via SSH for the ssh_backup_restore tool implementation.
     */
    export function buildRestoreCommand(backupType, backupFile, options = {}) {
      switch (backupType) {
      case BACKUP_TYPES.MYSQL:
        return buildMySQLRestoreCommand(backupFile, options);
      case BACKUP_TYPES.POSTGRESQL:
        return buildPostgreSQLRestoreCommand(backupFile, options);
      case BACKUP_TYPES.MONGODB:
        return buildMongoDBRestoreCommand(backupFile, options);
      case BACKUP_TYPES.FILES:
        return buildFilesRestoreCommand(backupFile, options);
      default:
        throw new Error(`Unknown backup type: ${backupType}`);
      }
    }
    
    /**
     * Build MySQL restore command
     */
    function buildMySQLRestoreCommand(backupFile, options) {
      const {
        database,
        user,
        password,
        host = 'localhost',
        port = 3306
      } = options;
    
      let command = '';
    
      // Decompress if needed
      if (backupFile.endsWith('.gz')) {
        command = `gunzip -c "${backupFile}" | `;
      } else {
        command = `cat "${backupFile}" | `;
      }
    
      command += 'mysql';
    
      // Connection parameters
      if (user) command += ` -u${user}`;
      if (password) command += ` -p'${password}'`;
      if (host) command += ` -h ${host}`;
      if (port) command += ` -P ${port}`;
      if (database) command += ` ${database}`;
    
      return command;
    }
    
    /**
     * Build PostgreSQL restore command
     */
    function buildPostgreSQLRestoreCommand(backupFile, options) {
      const {
        database,
        user,
        password,
        host = 'localhost',
        port = 5432
      } = options;
    
      let command = '';
      if (password) {
        command = `PGPASSWORD='${password}' `;
      }
    
      command += 'pg_restore';
    
      // Connection parameters
      if (user) command += ` -U ${user}`;
      if (host) command += ` -h ${host}`;
      if (port) command += ` -p ${port}`;
      if (database) command += ` -d ${database}`;
    
      // Restore options
      command += ' --clean --if-exists';
    
      // Handle compressed files
      if (backupFile.endsWith('.gz')) {
        command = `gunzip -c "${backupFile}" | ${command}`;
      } else {
        command += ` "${backupFile}"`;
      }
    
      return command;
    }
    
    /**
     * Build MongoDB restore command
     */
    function buildMongoDBRestoreCommand(backupFile, options) {
      const {
        database,
        user,
        password,
        host = 'localhost',
        port = 27017,
        drop = true
      } = options;
    
      let command = '';
    
      // Extract if compressed
      if (backupFile.endsWith('.tar.gz')) {
        const extractDir = backupFile.replace('.tar.gz', '');
        command = `tar -xzf "${backupFile}" -C "$(dirname ${backupFile})" && `;
        command += 'mongorestore';
    
        if (drop) command += ' --drop';
        if (host) command += ` --host ${host}`;
        if (port) command += ` --port ${port}`;
        if (user) command += ` --username ${user}`;
        if (password) command += ` --password '${password}'`;
    
        command += ` "${extractDir}"`;
        command += ` && rm -rf "${extractDir}"`;
      } else {
        command = 'mongorestore';
        if (drop) command += ' --drop';
        if (host) command += ` --host ${host}`;
        if (port) command += ` --port ${port}`;
        if (user) command += ` --username ${user}`;
        if (password) command += ` --password '${password}'`;
        command += ` "${backupFile}"`;
      }
    
      return command;
    }
    
    /**
     * Build files restore command
     */
    function buildFilesRestoreCommand(backupFile, options) {
      const { targetPath = '/' } = options;
    
      let command = 'tar';
    
      // Auto-detect compression
      if (backupFile.endsWith('.gz') || backupFile.endsWith('.tgz')) {
        command += ' -xzf';
      } else {
        command += ' -xf';
      }
    
      command += ` "${backupFile}"`;
      command += ` -C "${targetPath}"`;
    
      return command;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Restore' implies a write operation, it doesn't specify whether this is destructive, what permissions are required, whether it overwrites existing data, or what happens on failure. Significant behavioral details are missing for a potentially critical operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's appropriately sized for a tool with comprehensive schema documentation and gets straight to the point without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex restore operation with 9 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what gets restored (files vs databases), what the restore process entails, what happens to existing data, or what the tool returns. The schema handles parameter documentation well, but the overall context is incomplete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 9 parameters thoroughly. The description adds no additional parameter information beyond what's in the schema, meeting the baseline expectation but not providing extra value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Restore') and target ('from a backup on remote server'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'ssh_backup_create' or 'ssh_backup_list', which would be needed for a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'ssh_backup_create' or 'ssh_db_import', nor does it mention prerequisites or exclusions. It simply states what the tool does without context about appropriate use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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