Skip to content
Contact Us

Setup

Complete guide to setting up MirthSync for your Mirth Connect or Open Integration Engine environment. This guide assumes you’ve already installed MirthSync.


Setting up MirthSync is straightforward and takes about 5-10 minutes. This guide walks you through each step with platform-specific examples for Linux, macOS, and Windows.

Five-step MirthSync setup process from configure to Git init
  1. Configure Server Connection - Set up secure connection to your Mirth Connect or OIE server using environment variables
  2. Choose Target Directory - Select where MirthSync saves your configurations for version control
  3. Select Disk Mode - Pick how files are organized - from granular code extraction to single backup files
  4. Your First Pull - Download your configurations from the server to local files
  5. Initialize Git (Optional) - Set up version control for tracking changes, team collaboration, and rollback capability

MirthSync needs three pieces of information to connect to your Mirth Connect or OIE server:

  • Server URL - Full API URL (must include /api)
  • Username - API username
  • Password - API password

Provide credentials directly on the command line:

Terminal window
./mirthsync.sh \
-s https://mirth.example.com:8443/api \
-u admin \
-p your_password \
-t ./mirth-config \
pull

The target directory is where MirthSync saves your configurations. Choose a location that:

  • Has sufficient disk space
  • Is backed up regularly
  • Can be used as a Git repository
  • Is accessible by your development tools

Common patterns:

Terminal window
# Project-specific directory
./mirthsync.sh -s https://mirth.example.com:8443/api -u admin -t ./mirth-config pull
# Dedicated repository directory
./mirthsync.sh -s https://mirth.example.com:8443/api -u admin -t ~/projects/mirth-prod-config pull
# Shared team directory
./mirthsync.sh -s https://mirth.example.com:8443/api -u admin -t /opt/mirth-configs/production pull

MirthSync supports 4 disk modes that control how files are organized. Choose based on your workflow:

ModeDescriptionBest ForFile Count
code (default)Most granular - extracts JavaScript/SQL to separate filesDevelopment, code review, IDE integrationHigh (many files)
itemsIndividual XML files for channels and code templatesVersion control, simple structureMedium
groupsChannel groups and code template librariesTeam collaboration, logical groupingLow
backupSingle XML file (equivalent to Mirth Admin backup)Quick backups, migration1 file

Most granular mode - extracts JavaScript and SQL to separate files.

Terminal window
# Default mode (no -m flag needed)
./mirthsync.sh -s https://localhost:8443/api -u admin -t ./mirth-config pull
# Explicit mode specification
./mirthsync.sh -s https://localhost:8443/api -u admin -m code -t ./mirth-config pull

Structure:

mirth-config/
├── Channels/
│ ├── Default Group/
│ │ └── ADT_Inbound/
│ │ ├── channel.xml
│ │ ├── sourceConnector.js
│ │ ├── destinationConnector_1.js
│ │ └── transformer.js
│ └── Production Group/
│ └── Lab_Results/
│ └── ...
├── CodeTemplates/
│ ├── Utilities/
│ │ ├── library.xml
│ │ └── parseHL7.js
│ └── ...
├── GlobalScripts/
└── Resources/

Best for: Development, code review, IDE integration


Now let’s perform your first pull to download configurations from your server:

Terminal window
# 1. Create target directory
mkdir -p ./mirth-config
# 2. Pull from server (using environment variable for password)
export MIRTHSYNC_PASSWORD="your_password"
./mirthsync.sh -s https://mirth.example.com:8443/api -u admin -t ./mirth-config pull
# 3. Check what was downloaded
ls -la ./mirth-config/

Expected output:

Connecting to Mirth Connect...
✓ Connected to https://mirth.example.com:8443
✓ Pulled 15 channels
✓ Pulled 8 code templates
✓ Pulled configuration map
✓ Files saved to ./mirth-config/

Section titled “Step 5: Initialize Git (Optional but Recommended)”

Version control with Git is optional but highly recommended for tracking changes, team collaboration, and rollback capability.

MirthSync includes embedded Git functionality:

Terminal window
# Initialize git repository
./mirthsync.sh -t ./mirth-config git init
# Stage all files
./mirthsync.sh -t ./mirth-config git add
# Create first commit
./mirthsync.sh -t ./mirth-config --commit-message "Initial commit from production server" git commit
# Check status
./mirthsync.sh -t ./mirth-config git status

For convenience, MirthSync can automatically commit after pull operations:

Terminal window
# Pull and auto-commit in one command
./mirthsync.sh \
-s https://mirth.example.com:8443/api \
-u admin \
-t ./mirth-config \
--git-init \
--auto-commit \
--commit-message "Pulled from production $(date +%Y-%m-%d)" \
pull


Daily development setup:

Terminal window
# Morning: Pull latest from dev server
./mirthsync.sh -s https://mirth-dev:8443/api -u admin -t ./mirth-dev pull
# Work on channels in Admin Console or edit files directly
# Afternoon: Pull changes, review, and commit
./mirthsync.sh -s https://mirth-dev:8443/api -u admin -t ./mirth-dev pull
./mirthsync.sh -t ./mirth-dev git diff
./mirthsync.sh -t ./mirth-dev git add
./mirthsync.sh -t ./mirth-dev --commit-message "Updated ADT channel error handling" git commit
./mirthsync.sh -t ./mirth-dev git push

Managing multiple servers (dev, staging, production):

Terminal window
# Create separate directories for each environment
mkdir -p ./mirth-dev ./mirth-staging ./mirth-prod
# Set environment-specific passwords
export DEV_PASSWORD="dev_pass"
export STAGING_PASSWORD="staging_pass"
export PROD_PASSWORD="prod_pass"
# Pull from each environment
./mirthsync.sh -s https://mirth-dev:8443/api -u admin -p $DEV_PASSWORD -t ./mirth-dev pull
./mirthsync.sh -s https://mirth-staging:8443/api -u admin -p $STAGING_PASSWORD -t ./mirth-staging pull
./mirthsync.sh -s https://mirth-prod:8443/api -u admin -p $PROD_PASSWORD -t ./mirth-prod pull
# Or use a single directory with branches
./mirthsync.sh -s https://mirth-dev:8443/api -u admin -t ./mirth-config pull
./mirthsync.sh -t ./mirth-config git add
./mirthsync.sh -t ./mirth-config --commit-message "Dev environment snapshot" git commit
cd ./mirth-config && git checkout -b staging && cd .. # Use native git for branch creation
./mirthsync.sh -s https://mirth-staging:8443/api -u admin -t ./mirth-config pull

Automated pull in CI/CD pipeline:

Terminal window
# GitHub Actions, GitLab CI, Jenkins, etc.
# Set MIRTHSYNC_PASSWORD as secret/protected environment variable
# Pull from dev server
./mirthsync.sh \
-s ${MIRTH_DEV_URL} \
-u ${MIRTH_USERNAME} \
-i \
-t ./src \
--auto-commit \
--commit-message "Automated pull from dev - $(date)" \
--git-author "CI System" \
--git-email "ci@company.com" \
pull
# Push to GitHub
./mirthsync.sh -t ./src git push

”Connection refused” or “Cannot connect”

Section titled “”Connection refused” or “Cannot connect””

Check:

  1. Server is running: Open Mirth Administrator to verify
  2. API port is accessible: Default is 8443
  3. URL includes /api: https://mirth.example.com:8443/api
  4. Firewall allows connections on port 8443

Test connection:

Terminal window
# Test if API is accessible
curl -k https://mirth.example.com:8443/api/server/version

Check:

  1. Username is correct (usually admin)
  2. Password is correct
  3. User has API access enabled in Mirth Connect
  4. MIRTHSYNC_PASSWORD environment variable is set correctly

Verify environment variable:

Terminal window
echo $MIRTHSYNC_PASSWORD

If the target directory already has files:

Terminal window
# Use --force to overwrite existing files
./mirthsync.sh -s https://localhost:8443/api -u admin -f -t ./mirth-config pull

When files exist locally but not on server:

Terminal window
# See warnings (default behavior)
./mirthsync.sh -s https://localhost:8443/api -u admin -t ./mirth-config pull
# Delete orphaned files automatically
./mirthsync.sh -s https://localhost:8443/api -u admin --delete-orphaned -t ./mirth-config pull
# Delete with interactive confirmation
./mirthsync.sh -s https://localhost:8443/api -u admin --delete-orphaned --interactive -t ./mirth-config pull