A CLI tool for migrating from Mattermost to Matrix Synapse with multi-step, resumable migration support.
- Multi-step Migration: Migrate users, teams, channels, and memberships in organized steps
- SSH Tunnel Support: Securely connect to remote servers via SSH port forwarding
- Flexible SSH Authentication: Support for both SSH key and password-based authentication
- Auto-discovery: Automatically reads Mattermost database credentials from
config.json - Flexible Matrix Auth: Login with username/password or use existing admin token
- Beautiful TUI: Interactive terminal UI powered by Bubble Tea with styled menus
- Multi-language Support: English (default) and Turkish interfaces
- Detailed Connection Tests: Step-by-step connection diagnostics for precise troubleshooting
- Resumable: Checkpoint-based migration that can be paused and resumed
- Mapping Files: Generates mapping files to track Mattermost → Matrix entity relationships
- Application Service Support: Import messages with original timestamps
go install github.com/aligundogdu/matrixmigrate/cmd/matrixmigrate@latestOr build from source:
git clone https://github.com/aligundogdu/matrixmigrate.git
cd matrixmigrate
make build-
Copy the example configuration:
cp config.example.yaml config.yaml
-
Edit
config.yamlwith your server details:
mattermost:
ssh:
host: "mattermost.example.com"
user: "admin"
key_path: "~/.ssh/id_rsa"
config_path: "/opt/mattermost/config/config.json"
matrix:
ssh:
host: "matrix.example.com"
user: "admin"
key_path: "~/.ssh/id_rsa"
auth:
username: "admin"
password_env: "MATRIX_ADMIN_PASSWORD"
homeserver: "example.com"mattermost:
ssh:
host: "mattermost.example.com"
user: "root"
password_env: "MM_SSH_PASSWORD" # Uses environment variable
config_path: "/opt/mattermost/config/config.json"
matrix:
ssh:
host: "matrix.example.com"
user: "root"
password_env: "MX_SSH_PASSWORD"
auth:
username: "admin"
password_env: "MATRIX_ADMIN_PASSWORD"
homeserver: "example.com"- Set environment variables:
# For SSH password authentication export MM_SSH_PASSWORD="your-mattermost-ssh-password" export MX_SSH_PASSWORD="your-matrix-ssh-password" # For Matrix admin login export MATRIX_ADMIN_PASSWORD="your-admin-password"
Mattermost: The tool connects via SSH and reads /opt/mattermost/config/config.json to get database credentials. No manual database configuration needed!
Matrix: The tool logs in with username/password to get an access token. Alternatively, you can provide an existing admin token via MATRIX_ADMIN_TOKEN environment variable.
# Start with default language (English)
./matrixmigrate
# Start with Turkish interface
./matrixmigrate --lang tr# Run specific steps
./matrixmigrate export assets
./matrixmigrate import assets
./matrixmigrate export memberships
./matrixmigrate import memberships
./matrixmigrate export messages
./matrixmigrate import messages
# Run with specific config
./matrixmigrate --config ./config.yaml export assetsThe connection test provides detailed step-by-step diagnostics:
# Test all connections
./matrixmigrate test all
# Test individual connections
./matrixmigrate test mattermost
./matrixmigrate test matrixTest Output Example:
📋 Configuration
✓ Configuration file loaded (config.yaml found and parsed)
✓ Data directories accessible (Assets: ./data/assets, Mappings: ./data/mappings)
🗄️ Mattermost
✓ SSH configuration (Password auth via $MM_SSH_PASSWORD)
✓ SSH connection (root@mattermost.example.com:22)
✓ Mattermost config.json (/opt/mattermost/config/config.json)
✓ Database connection (150 users, 12 teams, 87 channels)
🔷 Matrix
✓ SSH configuration (Key: ~/.ssh/id_rsa)
✓ SSH connection (admin@matrix.example.com:22)
✓ API authentication (Login as admin via $MATRIX_ADMIN_PASSWORD)
✓ API connection (Homeserver: example.com)
⚠ Application Service (Not configured - message timestamps won't be preserved)
✓ All connection tests passed!
./matrixmigrate status| Step | Command | Description |
|---|---|---|
| 1a | export assets |
Export users, teams, channels from Mattermost |
| 1b | import assets |
Create users, spaces, rooms in Matrix |
| 2a | export memberships |
Export team/channel memberships from Mattermost |
| 2b | import memberships |
Apply memberships in Matrix |
| 3a | export messages |
Export all messages from Mattermost |
| 3b | import messages |
Import messages to Matrix rooms (requires Application Service for timestamps) |
+-------------------------------------------------------------+
| Local Machine |
| +--------------+ +----------+ +------------------------+ |
| | MatrixMigrate| | Config | | Data Store | |
| | CLI |--| YAML | | - assets/*.json.gz | |
| +------+-------+ +----------+ | - mappings/*.json | |
| | | - state.json | |
| | +------------------------+ |
+---------+-------------------------------------------------------+
|
+-----+-----+
| |
v v
+----------+ +----------+
|Mattermost| | Matrix |
|SSH (key/ | |SSH (key/ |
| password)| | password)|
| | | | | |
| v | | v |
|config.json | API |
| | | | | |
| v | | v |
|PostgreSQL| |Login/Token
+----------+ +----------+
| Mattermost | Matrix |
|---|---|
| Team | Space |
| Channel | Room |
| User | User |
| Team Membership | Space Membership |
| Channel Membership | Room Membership |
| Variable | Description | Required |
|---|---|---|
MATRIX_ADMIN_PASSWORD |
Matrix admin password for login | Yes (if using auth) |
MATRIX_ADMIN_TOKEN |
Alternative: existing admin token | No |
MATRIX_AS_TOKEN |
Application Service token for message import | Yes (for messages) |
MM_SSH_PASSWORD |
Mattermost SSH password | No (if using key) |
MX_SSH_PASSWORD |
Matrix SSH password | No (if using key) |
SSH_KEY_PASSPHRASE |
SSH key passphrase (if encrypted) | No |
If you're getting too many 429 (rate limit) errors during migration, you have two options:
Add rate limiting configuration to your config.yaml:
matrix:
rate_limit:
# Requests per second (lower = slower but safer, 0 = no limit)
# Default: 5.0 (200ms between requests)
requests_per_second: 2.0
# Maximum retries when rate limited (429 error)
# Default: 5
max_retries: 10
# Base delay in milliseconds for exponential backoff
# Actual delay: base_delay * 2^retry_count (e.g., 2s, 4s, 8s, 16s, 32s)
# Default: 2000 (2 seconds)
retry_base_delay_ms: 3000Add this to your Synapse homeserver.yaml:
rc_message:
per_second: 10000
burst_count: 10000
rc_registration:
per_second: 10000
burst_count: 10000
rc_login:
address:
per_second: 10000
burst_count: 10000
account:
per_second: 10000
burst_count: 10000
failed_attempts:
per_second: 10000
burst_count: 10000
rc_admin_redaction:
per_second: 10000
burst_count: 10000
rc_joins:
local:
per_second: 10000
burst_count: 10000
remote:
per_second: 10000
burst_count: 10000
rc_invites:
per_room:
per_second: 10000
burst_count: 10000
per_user:
per_second: 10000
burst_count: 10000
rc_room_creation:
per_second: 10000
burst_count: 10000systemctl restart matrix-synapse) and re-enable rate limiting after the migration is complete for security!
Even if you configure all rate limit bypass settings, some items may still fail to import due to rate limiting or temporary network issues. Don't panic!
The migration tool is designed to be resumable:
- Already imported users, spaces, and rooms are tracked in the mapping file
- When you run the import command again, it will skip already imported items and only process the failed ones
- Simply wait a few minutes and run the same import command again
- Repeat until all items are successfully imported
This is normal behavior and the tool will eventually complete all imports.
To import messages with their original timestamps, you need to configure an Application Service (AS) on your Synapse server. Without AS, messages will be imported with the current timestamp.
Note: The connection test will show a warning (⚠) if Application Service is not configured, reminding you that message timestamps won't be preserved.
# Generate AS token
openssl rand -hex 32
# Example output: a1b2c3d4e5f6...
# Generate HS token
openssl rand -hex 32
# Example output: 9z8y7x6w5v4u...Create a file on your Synapse server (e.g., /etc/matrix-synapse/matrixmigrate.yaml):
id: matrixmigrate
url: null # No callback URL needed - outbound only
as_token: "YOUR_GENERATED_AS_TOKEN"
hs_token: "YOUR_GENERATED_HS_TOKEN"
sender_localpart: matrixmigrate
rate_limited: false # Disable rate limiting for AS
namespaces:
users: []
rooms: []
aliases: []Add to your homeserver.yaml:
app_service_config_files:
- /etc/matrix-synapse/matrixmigrate.yamlThen restart Synapse:
systemctl restart matrix-synapseAdd to your config.yaml:
matrix:
appservice:
enabled: true
as_token_env: "MATRIX_AS_TOKEN"Set the environment variable:
export MATRIX_AS_TOKEN="YOUR_GENERATED_AS_TOKEN"./matrixmigrate import messagesNote: The AS token allows the migration tool to send messages on behalf of users with their original timestamps. This is the only way to preserve message history accurately.
Use ./matrixmigrate test all to identify exactly where the connection fails.
- For key auth: Ensure SSH key is properly configured and has correct permissions
- For password auth: Check that the password environment variable is set
- Verify the SSH port is correct (default: 22)
- Check the
config_pathin your config.yaml - Try different paths:
/opt/mattermost/config/config.json,/opt/mattermost/config.json - Ensure the SSH user has read access to the file
- Verify the admin username and password
- Check if the Matrix homeserver supports password login
- Ensure the user has admin privileges
- The tool reads credentials from Mattermost's config.json automatically
- Ensure PostgreSQL is running and accessible from localhost on the Mattermost server
- If you see "⚠ Application Service (Not configured)" in the connection test, this means:
- Messages will be imported with current timestamps instead of original timestamps
- To fix: Follow the "Application Service Setup" section above
MIT License
Mattermost'tan Matrix Synapse'a çok adımlı, devam ettirilebilir taşıma desteği sunan bir CLI aracı.
- Çok Adımlı Taşıma: Kullanıcıları, takımları, kanalları ve üyelikleri düzenli adımlarla taşıyın
- SSH Tünel Desteği: SSH port yönlendirme ile uzak sunuculara güvenli bağlantı
- Esnek SSH Kimlik Doğrulama: SSH anahtarı veya şifre tabanlı kimlik doğrulama desteği
- Otomatik Keşif: Mattermost veritabanı bilgilerini
config.jsondosyasından otomatik okur - Esnek Matrix Kimlik Doğrulama: Kullanıcı adı/şifre ile giriş veya mevcut admin token kullanımı
- Güzel TUI: Bubble Tea ile geliştirilmiş, stilli menülere sahip etkileşimli terminal arayüzü
- Çoklu Dil Desteği: İngilizce (varsayılan) ve Türkçe arayüz
- Detaylı Bağlantı Testleri: Sorunları tam olarak belirlemek için adım adım bağlantı tanılama
- Devam Ettirilebilir: Duraklatılıp devam ettirilebilen kontrol noktası tabanlı taşıma
- Eşleme Dosyaları: Mattermost → Matrix varlık ilişkilerini izlemek için eşleme dosyaları oluşturur
- Application Service Desteği: Mesajları orijinal zaman damgalarıyla aktarın
go install github.com/aligundogdu/matrixmigrate/cmd/matrixmigrate@latestVeya kaynaktan derleyin:
git clone https://github.com/aligundogdu/matrixmigrate.git
cd matrixmigrate
make build-
Örnek yapılandırmayı kopyalayın:
cp config.example.yaml config.yaml
-
config.yamldosyasını sunucu bilgilerinizle düzenleyin:
mattermost:
ssh:
host: "mattermost.example.com"
user: "admin"
key_path: "~/.ssh/id_rsa"
config_path: "/opt/mattermost/config/config.json"
matrix:
ssh:
host: "matrix.example.com"
user: "admin"
key_path: "~/.ssh/id_rsa"
auth:
username: "admin"
password_env: "MATRIX_ADMIN_PASSWORD"
homeserver: "example.com"mattermost:
ssh:
host: "mattermost.example.com"
user: "root"
password_env: "MM_SSH_PASSWORD" # Ortam değişkeni kullanır
config_path: "/opt/mattermost/config/config.json"
matrix:
ssh:
host: "matrix.example.com"
user: "root"
password_env: "MX_SSH_PASSWORD"
auth:
username: "admin"
password_env: "MATRIX_ADMIN_PASSWORD"
homeserver: "example.com"- Ortam değişkenlerini ayarlayın:
# SSH şifre kimlik doğrulaması için export MM_SSH_PASSWORD="mattermost-ssh-sifreniz" export MX_SSH_PASSWORD="matrix-ssh-sifreniz" # Matrix admin girişi için export MATRIX_ADMIN_PASSWORD="admin-sifreniz"
Mattermost: Araç SSH ile bağlanır ve veritabanı bilgilerini almak için /opt/mattermost/config/config.json dosyasını okur. Manuel veritabanı yapılandırmasına gerek yok!
Matrix: Araç erişim token'ı almak için kullanıcı adı/şifre ile giriş yapar. Alternatif olarak, MATRIX_ADMIN_TOKEN ortam değişkeni ile mevcut bir admin token sağlayabilirsiniz.
# Varsayılan dil (İngilizce) ile başlat
./matrixmigrate
# Türkçe arayüz ile başlat
./matrixmigrate --lang tr# Belirli adımları çalıştır
./matrixmigrate export assets
./matrixmigrate import assets
./matrixmigrate export memberships
./matrixmigrate import memberships
./matrixmigrate export messages
./matrixmigrate import messages
# Belirli config ile çalıştır
./matrixmigrate --config ./config.yaml export assetsBağlantı testi detaylı adım adım tanılama sağlar:
# Tüm bağlantıları test et
./matrixmigrate test all
# Ayrı ayrı bağlantıları test et
./matrixmigrate test mattermost
./matrixmigrate test matrixTest Çıktısı Örneği:
📋 Yapılandırma
✓ Yapılandırma dosyası yüklendi (config.yaml bulundu ve ayrıştırıldı)
✓ Veri dizinleri erişilebilir (Assets: ./data/assets, Mappings: ./data/mappings)
🗄️ Mattermost
✓ SSH yapılandırması ($MM_SSH_PASSWORD ile şifre doğrulama)
✓ SSH bağlantısı (root@mattermost.example.com:22)
✓ Mattermost config.json (/opt/mattermost/config/config.json)
✓ Veritabanı bağlantısı (150 kullanıcı, 12 takım, 87 kanal)
🔷 Matrix
✓ SSH yapılandırması (Anahtar: ~/.ssh/id_rsa)
✓ SSH bağlantısı (admin@matrix.example.com:22)
✓ API kimlik doğrulama ($MATRIX_ADMIN_PASSWORD ile admin olarak giriş)
✓ API bağlantısı (Homeserver: example.com)
⚠ Application Service (Yapılandırılmamış - mesaj zaman damgaları korunmayacak)
✓ Tüm bağlantı testleri başarılı!
./matrixmigrate status| Adım | Komut | Açıklama |
|---|---|---|
| 1a | export assets |
Mattermost'tan kullanıcıları, takımları, kanalları dışa aktar |
| 1b | import assets |
Matrix'te kullanıcıları, space'leri, odaları oluştur |
| 2a | export memberships |
Mattermost'tan takım/kanal üyeliklerini dışa aktar |
| 2b | import memberships |
Matrix'te üyelikleri uygula |
| 3a | export messages |
Mattermost'tan tüm mesajları dışa aktar |
| 3b | import messages |
Mesajları Matrix odalarına aktar (zaman damgaları için Application Service gerektirir) |
+-------------------------------------------------------------+
| Yerel Makine |
| +--------------+ +----------+ +------------------------+ |
| | MatrixMigrate| | Config | | Veri Deposu | |
| | CLI |--| YAML | | - assets/*.json.gz | |
| +------+-------+ +----------+ | - mappings/*.json | |
| | | - state.json | |
| | +------------------------+ |
+---------+-------------------------------------------------------+
|
+-----+-----+
| |
v v
+----------+ +----------+
|Mattermost| | Matrix |
|SSH(anahtar| |SSH(anahtar|
| /şifre) | | /şifre) |
| | | | | |
| v | | v |
|config.json | API |
| | | | | |
| v | | v |
|PostgreSQL| |Giriş/Token
+----------+ +----------+
| Mattermost | Matrix |
|---|---|
| Team | Space |
| Channel | Room |
| User | User |
| Team Membership | Space Membership |
| Channel Membership | Room Membership |
| Değişken | Açıklama | Zorunlu |
|---|---|---|
MATRIX_ADMIN_PASSWORD |
Giriş için Matrix admin şifresi | Evet (auth kullanılıyorsa) |
MATRIX_ADMIN_TOKEN |
Alternatif: mevcut admin token | Hayır |
MATRIX_AS_TOKEN |
Mesaj aktarımı için Application Service token | Evet (mesajlar için) |
MM_SSH_PASSWORD |
Mattermost SSH şifresi | Hayır (anahtar kullanılıyorsa) |
MX_SSH_PASSWORD |
Matrix SSH şifresi | Hayır (anahtar kullanılıyorsa) |
SSH_KEY_PASSPHRASE |
SSH anahtar parolası (şifreli ise) | Hayır |
Migrasyon sırasında çok fazla 429 (hız sınırı) hatası alıyorsanız, iki seçeneğiniz var:
config.yaml dosyanıza hız sınırlama yapılandırması ekleyin:
matrix:
rate_limit:
# Saniyede istek sayısı (düşük = yavaş ama güvenli, 0 = sınırsız)
# Varsayılan: 5.0 (istekler arası 200ms)
requests_per_second: 2.0
# Hız sınırı hatası (429) alındığında maksimum deneme sayısı
# Varsayılan: 5
max_retries: 10
# Üstel geri çekilme için milisaniye cinsinden temel gecikme
# Gerçek gecikme: temel_gecikme * 2^deneme_sayısı (örn. 2s, 4s, 8s, 16s, 32s)
# Varsayılan: 2000 (2 saniye)
retry_base_delay_ms: 3000Synapse homeserver.yaml dosyanıza şunu ekleyin:
rc_message:
per_second: 10000
burst_count: 10000
rc_registration:
per_second: 10000
burst_count: 10000
rc_login:
address:
per_second: 10000
burst_count: 10000
account:
per_second: 10000
burst_count: 10000
failed_attempts:
per_second: 10000
burst_count: 10000
rc_admin_redaction:
per_second: 10000
burst_count: 10000
rc_joins:
local:
per_second: 10000
burst_count: 10000
remote:
per_second: 10000
burst_count: 10000
rc_invites:
per_room:
per_second: 10000
burst_count: 10000
per_user:
per_second: 10000
burst_count: 10000
rc_room_creation:
per_second: 10000
burst_count: 10000systemctl restart matrix-synapse) ve güvenlik için migrasyon tamamlandıktan sonra hız sınırlamayı tekrar etkinleştirmeyi unutmayın!
Tüm hız sınırı bypass ayarlarını yapılandırsanız bile, hız sınırlaması veya geçici ağ sorunları nedeniyle bazı öğeler aktarılamayabilir. Panik yapmayın!
Migrasyon aracı devam ettirilebilir olarak tasarlanmıştır:
- Zaten aktarılmış kullanıcılar, space'ler ve odalar mapping dosyasında takip edilir
- Import komutunu tekrar çalıştırdığınızda, zaten aktarılmış öğeleri atlayacak ve sadece başarısız olanları işleyecektir
- Birkaç dakika bekleyin ve aynı import komutunu tekrar çalıştırın
- Tüm öğeler başarıyla aktarılana kadar tekrarlayın
Bu normal bir davranıştır ve araç sonunda tüm aktarımları tamamlayacaktır.
Mesajları orijinal zaman damgalarıyla aktarmak için Synapse sunucunuzda bir Application Service (AS) yapılandırmanız gerekir. AS olmadan mesajlar mevcut zaman damgasıyla aktarılır.
Not: Bağlantı testi, Application Service yapılandırılmamışsa bir uyarı (⚠) gösterecek ve mesaj zaman damgalarının korunmayacağını hatırlatacaktır.
# AS token oluştur
openssl rand -hex 32
# Örnek çıktı: a1b2c3d4e5f6...
# HS token oluştur
openssl rand -hex 32
# Örnek çıktı: 9z8y7x6w5v4u...Synapse sunucunuzda bir dosya oluşturun (örn. /etc/matrix-synapse/matrixmigrate.yaml):
id: matrixmigrate
url: null # Callback URL gerekli değil - sadece giden
as_token: "OLUŞTURDUĞUNUZ_AS_TOKEN"
hs_token: "OLUŞTURDUĞUNUZ_HS_TOKEN"
sender_localpart: matrixmigrate
rate_limited: false # AS için hız sınırlamasını devre dışı bırak
namespaces:
users: []
rooms: []
aliases: []homeserver.yaml dosyanıza ekleyin:
app_service_config_files:
- /etc/matrix-synapse/matrixmigrate.yamlArdından Synapse'i yeniden başlatın:
systemctl restart matrix-synapseconfig.yaml dosyanıza ekleyin:
matrix:
appservice:
enabled: true
as_token_env: "MATRIX_AS_TOKEN"Ortam değişkenini ayarlayın:
export MATRIX_AS_TOKEN="OLUŞTURDUĞUNUZ_AS_TOKEN"./matrixmigrate import messagesNot: AS token'ı, migrasyon aracının kullanıcılar adına orijinal zaman damgalarıyla mesaj göndermesini sağlar. Mesaj geçmişini doğru şekilde korumak için tek yol budur.
Bağlantının tam olarak nerede başarısız olduğunu belirlemek için ./matrixmigrate test all kullanın.
- Anahtar doğrulama için: SSH anahtarının düzgün yapılandırıldığından ve doğru izinlere sahip olduğundan emin olun
- Şifre doğrulama için: Şifre ortam değişkeninin ayarlandığını kontrol edin
- SSH portunun doğru olduğunu doğrulayın (varsayılan: 22)
- config.yaml dosyanızdaki
config_pathdeğerini kontrol edin - Farklı yolları deneyin:
/opt/mattermost/config/config.json,/opt/mattermost/config.json - SSH kullanıcısının dosyaya okuma erişimi olduğundan emin olun
- Admin kullanıcı adı ve şifresini doğrulayın
- Matrix homeserver'ın şifre girişini destekleyip desteklemediğini kontrol edin
- Kullanıcının admin yetkilerine sahip olduğundan emin olun
- Araç, kimlik bilgilerini Mattermost'un config.json dosyasından otomatik olarak okur
- PostgreSQL'in çalıştığından ve Mattermost sunucusunda localhost'tan erişilebilir olduğundan emin olun
- Bağlantı testinde "⚠ Application Service (Yapılandırılmamış)" görüyorsanız, bu şu anlama gelir:
- Mesajlar orijinal zaman damgaları yerine mevcut zaman damgasıyla aktarılacak
- Düzeltmek için: Yukarıdaki "Application Service Kurulumu" bölümünü takip edin
MIT Lisansı

