Setup
MirthSync Setup
Section titled “MirthSync Setup”Complete guide to setting up MirthSync for your Mirth Connect or Open Integration Engine environment. This guide assumes you’ve already installed MirthSync.
Overview
Section titled “Overview”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.
What You’ll Accomplish
Section titled “What You’ll Accomplish”- Configure Server Connection - Set up secure connection to your Mirth Connect or OIE server using environment variables
- Choose Target Directory - Select where MirthSync saves your configurations for version control
- Select Disk Mode - Pick how files are organized - from granular code extraction to single backup files
- Your First Pull - Download your configurations from the server to local files
- Initialize Git (Optional) - Set up version control for tracking changes, team collaboration, and rollback capability
Step 1: Configure Server Connection
Section titled “Step 1: Configure Server Connection”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:
./mirthsync.sh \ -s https://mirth.example.com:8443/api \ -u admin \ -p your_password \ -t ./mirth-config \ pull./mirthsync.sh \ -s https://mirth.example.com:8443/api \ -u admin \ -p your_password \ -t ./mirth-config \ pullmirthsync.bat ` -s https://mirth.example.com:8443/api ` -u admin ` -p your_password ` -t ./mirth-config ` pullUse MIRTHSYNC_PASSWORD environment variable to keep passwords out of command line:
Set for current session:
export MIRTHSYNC_PASSWORD="your_password"Make permanent (add to ~/.bashrc or ~/.zshrc):
echo 'export MIRTHSYNC_PASSWORD="your_password"' >> ~/.bashrcsource ~/.bashrcUse .env file (recommended for development):
# Create .env filecat > .env << 'EOF'MIRTHSYNC_PASSWORD=your_passwordEOF
# Add to .gitignoreecho ".env" >> .gitignore
# Load before running mirthsyncsource .env./mirthsync.sh -s https://mirth.example.com:8443/api -u admin -t ./mirth-config pullSet for current session:
export MIRTHSYNC_PASSWORD="your_password"Make permanent (add to ~/.zshrc for newer macOS):
echo 'export MIRTHSYNC_PASSWORD="your_password"' >> ~/.zshrcsource ~/.zshrcUse .env file (recommended for development):
# Create .env filecat > .env << 'EOF'MIRTHSYNC_PASSWORD=your_passwordEOF
# Add to .gitignoreecho ".env" >> .gitignore
# Load before running mirthsyncsource .env./mirthsync.sh -s https://mirth.example.com:8443/api -u admin -t ./mirth-config pullPowerShell (current session):
$env:MIRTHSYNC_PASSWORD="your_password"PowerShell (permanent):
[System.Environment]::SetEnvironmentVariable('MIRTHSYNC_PASSWORD', 'your_password', 'User')Command Prompt (current session):
set MIRTHSYNC_PASSWORD=your_passwordPermanent (via System Properties):
- Search for “Environment Variables”
- Click “Edit the system environment variables”
- Click “Environment Variables” button
- Add
MIRTHSYNC_PASSWORDas user variable
Then run without -p flag:
# Password automatically read from MIRTHSYNC_PASSWORD./mirthsync.sh -s https://mirth.example.com:8443/api -u admin -t ./mirth-config pull# Password automatically read from MIRTHSYNC_PASSWORD./mirthsync.sh -s https://mirth.example.com:8443/api -u admin -t ./mirth-config pull# Password automatically read from MIRTHSYNC_PASSWORDmirthsync.bat -s https://mirth.example.com:8443/api -u admin -t ./mirth-config pullStep 2: Choose Target Directory
Section titled “Step 2: Choose Target Directory”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:
# 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# 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
# iCloud Drive (for backup)./mirthsync.sh -s https://mirth.example.com:8443/api -u admin -t ~/Library/Mobile\ Documents/com~apple~CloudDocs/mirth-config pull# Project-specific directorymirthsync.bat -s https://mirth.example.com:8443/api -u admin -t .\mirth-config pull
# Dedicated repository directorymirthsync.bat -s https://mirth.example.com:8443/api -u admin -t C:\Projects\mirth-prod-config pull
# Network share (for team access)mirthsync.bat -s https://mirth.example.com:8443/api -u admin -t \\server\mirth-configs\production pullStep 3: Select Disk Mode
Section titled “Step 3: Select Disk Mode”MirthSync supports 4 disk modes that control how files are organized. Choose based on your workflow:
| Mode | Description | Best For | File Count |
|---|---|---|---|
code (default) | Most granular - extracts JavaScript/SQL to separate files | Development, code review, IDE integration | High (many files) |
items | Individual XML files for channels and code templates | Version control, simple structure | Medium |
groups | Channel groups and code template libraries | Team collaboration, logical grouping | Low |
backup | Single XML file (equivalent to Mirth Admin backup) | Quick backups, migration | 1 file |
Mode Examples
Section titled “Mode Examples”Most granular mode - extracts JavaScript and SQL to separate files.
# 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# 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# Default mode (no -m flag needed)mirthsync.bat -s https://localhost:8443/api -u admin -t .\mirth-config pull
# Explicit mode specificationmirthsync.bat -s https://localhost:8443/api -u admin -m code -t .\mirth-config pullStructure:
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
Individual XML files for channels and code templates.
./mirthsync.sh -s https://localhost:8443/api -u admin -m items -t ./mirth-config pull./mirthsync.sh -s https://localhost:8443/api -u admin -m items -t ./mirth-config pullmirthsync.bat -s https://localhost:8443/api -u admin -m items -t .\mirth-config pullStructure:
mirth-config/├── Channels/│ ├── Default Group/│ │ └── ADT_Inbound.xml│ └── Production Group/│ └── Lab_Results.xml└── CodeTemplates/ ├── Utilities.xml └── ...Best for: Version control with simpler structure, quick edits
Channel groups and code template library level.
./mirthsync.sh -s https://localhost:8443/api -u admin -m groups -t ./mirth-config pull./mirthsync.sh -s https://localhost:8443/api -u admin -m groups -t ./mirth-config pullmirthsync.bat -s https://localhost:8443/api -u admin -m groups -t .\mirth-config pullStructure:
mirth-config/├── ChannelGroups/│ ├── Default Group.xml│ └── Production Group.xml└── CodeTemplateLibraries/ └── Utilities.xmlBest for: Team collaboration, logical grouping by channel groups
Single full backup XML file (equivalent to Mirth Administrator backup).
./mirthsync.sh -s https://localhost:8443/api -u admin -m backup -t ./mirth-config pull./mirthsync.sh -s https://localhost:8443/api -u admin -m backup -t ./mirth-config pullmirthsync.bat -s https://localhost:8443/api -u admin -m backup -t .\mirth-config pullStructure:
mirth-config/└── backup.xmlBest for: Quick backups, migration between servers, disaster recovery
Step 4: Your First Pull
Section titled “Step 4: Your First Pull”Now let’s perform your first pull to download configurations from your server:
# 1. Create target directorymkdir -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 downloadedls -la ./mirth-config/# 1. Create target directorymkdir -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 downloadedls -la ./mirth-config/# 1. Create target directoryNew-Item -ItemType Directory -Force -Path .\mirth-config
# 2. Pull from server (using environment variable for password)$env:MIRTHSYNC_PASSWORD="your_password"mirthsync.bat -s https://mirth.example.com:8443/api -u admin -t .\mirth-config pull
# 3. Check what was downloadeddir .\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/Step 5: Initialize Git (Optional but Recommended)
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:
# 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# 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# Initialize git repositorymirthsync.bat -t .\mirth-config git init
# Stage all filesmirthsync.bat -t .\mirth-config git add
# Create first commitmirthsync.bat -t .\mirth-config --commit-message "Initial commit from production server" git commit
# Check statusmirthsync.bat -t .\mirth-config git statusIf you prefer standard Git commands:
cd ./mirth-configgit initgit add .git commit -m "Initial commit from production server"git statuscd ..cd ./mirth-configgit initgit add .git commit -m "Initial commit from production server"git statuscd ..cd .\mirth-configgit initgit add .git commit -m "Initial commit from production server"git statuscd ..Auto-Commit Workflow
Section titled “Auto-Commit Workflow”For convenience, MirthSync can automatically commit after pull operations:
# 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# 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# Pull and auto-commit in one commandmirthsync.bat ` -s https://mirth.example.com:8443/api ` -u admin ` -t .\mirth-config ` --git-init ` --auto-commit ` --commit-message "Pulled from production $((Get-Date).ToString('yyyy-MM-dd'))" ` pullSecurity Best Practices
Section titled “Security Best Practices”Common Setup Patterns
Section titled “Common Setup Patterns”Development Workflow
Section titled “Development Workflow”Daily development setup:
# 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# 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# Morning: Pull latest from dev servermirthsync.bat -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 commitmirthsync.bat -s https://mirth-dev:8443/api -u admin -t .\mirth-dev pullmirthsync.bat -t .\mirth-dev git diffmirthsync.bat -t .\mirth-dev git addmirthsync.bat -t .\mirth-dev --commit-message "Updated ADT channel error handling" git commitmirthsync.bat -t .\mirth-dev git pushMulti-Environment Setup
Section titled “Multi-Environment Setup”Managing multiple servers (dev, staging, production):
# Create separate directories for each environmentmkdir -p ./mirth-dev ./mirth-staging ./mirth-prod
# Set environment-specific passwordsexport 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 commitcd ./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# Create separate directories for each environmentmkdir -p ./mirth-dev ./mirth-staging ./mirth-prod
# Set environment-specific passwordsexport 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 commitcd ./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# Create separate directories for each environmentNew-Item -ItemType Directory -Force -Path .\mirth-dev, .\mirth-staging, .\mirth-prod
# Set environment-specific passwords$env:DEV_PASSWORD="dev_pass"$env:STAGING_PASSWORD="staging_pass"$env:PROD_PASSWORD="prod_pass"
# Pull from each environmentmirthsync.bat -s https://mirth-dev:8443/api -u admin -p %DEV_PASSWORD% -t .\mirth-dev pullmirthsync.bat -s https://mirth-staging:8443/api -u admin -p %STAGING_PASSWORD% -t .\mirth-staging pullmirthsync.bat -s https://mirth-prod:8443/api -u admin -p %PROD_PASSWORD% -t .\mirth-prod pull
# Or use a single directory with branchesmirthsync.bat -s https://mirth-dev:8443/api -u admin -t .\mirth-config pullmirthsync.bat -t .\mirth-config git addmirthsync.bat -t .\mirth-config --commit-message "Dev environment snapshot" git commitcd .\mirth-config; git checkout -b staging; cd .. # Use native git for branch creationmirthsync.bat -s https://mirth-staging:8443/api -u admin -t .\mirth-config pullCI/CD Setup
Section titled “CI/CD Setup”Automated pull in CI/CD pipeline:
# 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# For local CI/CD testing# Set MIRTHSYNC_PASSWORD as 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# Azure DevOps, Jenkins on Windows, etc.# Set MIRTHSYNC_PASSWORD as secret/protected environment variable
# Pull from dev servermirthsync.bat ` -s ${env:MIRTH_DEV_URL} ` -u ${env:MIRTH_USERNAME} ` -i ` -t .\src ` --auto-commit ` --commit-message "Automated pull from dev - $((Get-Date).ToString())" ` --git-author "CI System" ` --git-email "ci@company.com" ` pull
# Push to GitHubmirthsync.bat -t .\src git pushTroubleshooting Setup
Section titled “Troubleshooting Setup””Connection refused” or “Cannot connect”
Section titled “”Connection refused” or “Cannot connect””Check:
- Server is running: Open Mirth Administrator to verify
- API port is accessible: Default is 8443
- URL includes
/api:https://mirth.example.com:8443/api - Firewall allows connections on port 8443
Test connection:
# Test if API is accessiblecurl -k https://mirth.example.com:8443/api/server/version# Test if API is accessiblecurl -k https://mirth.example.com:8443/api/server/version# Test if API is accessibleInvoke-WebRequest -Uri https://mirth.example.com:8443/api/server/version -SkipCertificateCheck“Authentication failed”
Section titled ““Authentication failed””Check:
- Username is correct (usually
admin) - Password is correct
- User has API access enabled in Mirth Connect
- MIRTHSYNC_PASSWORD environment variable is set correctly
Verify environment variable:
echo $MIRTHSYNC_PASSWORDecho $MIRTHSYNC_PASSWORDecho $env:MIRTHSYNC_PASSWORD“Target directory not empty”
Section titled ““Target directory not empty””If the target directory already has files:
# Use --force to overwrite existing files./mirthsync.sh -s https://localhost:8443/api -u admin -f -t ./mirth-config pull# Use --force to overwrite existing files./mirthsync.sh -s https://localhost:8443/api -u admin -f -t ./mirth-config pull# Use --force to overwrite existing filesmirthsync.bat -s https://localhost:8443/api -u admin -f -t .\mirth-config pullOrphaned File Warnings
Section titled “Orphaned File Warnings”When files exist locally but not on server:
# 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# 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# See warnings (default behavior)mirthsync.bat -s https://localhost:8443/api -u admin -t .\mirth-config pull
# Delete orphaned files automaticallymirthsync.bat -s https://localhost:8443/api -u admin --delete-orphaned -t .\mirth-config pull
# Delete with interactive confirmationmirthsync.bat -s https://localhost:8443/api -u admin --delete-orphaned --interactive -t .\mirth-config pull