Migrate and restore Kafka consumer group offsets between clusters — for cluster migrations, disaster recovery, and environment promotion.
Developed and maintained by Kannika.io — the Kafka reliability platform.
kbridge is an open-source CLI tool built in Rust that makes Kafka consumer offset migration safe, predictable, and scriptable. Whether you're moving to Confluent Cloud, recovering from a cluster failure, or syncing consumer state between environments, kbridge gives you full control with a simple three-step pipeline.
Kannika.io builds open-source and commercial tools for Kafka reliability, observability, and operations. kbridge is part of our toolchain for teams running Kafka in production.
# Show help
kbridge --help
# Show help for specific command
kbridge fetch --help
kbridge calculate --help
kbridge apply --helpAgainst local source (localhost:9092) and target (localhost:9093) clusters:
# Step 1: Fetch offsets from source cluster
kbridge fetch -b localhost:9092 > source_offsets.csv
# Step 2: Calculate target offsets
kbridge calculate -b localhost:9093 -H Offset -i source_offsets.csv > target_offsets.csv
# Step 3: Apply target offsets (with confirmation prompt)
kbridge apply -b localhost:9093 -i target_offsets.csvAll steps can be chained together for streamlined execution:
kbridge fetch -b localhost:9092 | \
kbridge calculate -b localhost:9093 -H Offset | \
kbridge apply -b localhost:9093
⚠️ Safety First: Before applying offsets, a confirmation prompt is shown to prevent accidental modifications. The prompt can be skipped by adding the '-y' flag to the apply step (See help section for more info).
The tool uses CSV format for offset data with the following columns:
consumer_group,topic,partition,offset
my-consumer-group,orders,0,12345
my-consumer-group,orders,1,12346
my-consumer-group,payments,0,5678cargo install --git https://github.com/cymo-eu/kannika-bridge.git kbridge- Download the latest binary for your platform from the releases page
- Extract the archive
- Move the
kbridgebinary to a directory in your$PATH
# Download and install (replace VERSION with actual version)
curl -L https://github.com/cymo-eu/kannika-bridge/releases/download/vVERSION/kbridge-linux.tar.gz | tar xz
sudo mv kbridge /usr/local/bin/No installation possible. In a later release, installation via Docker will be added.
Download the Windows executable from the releases page and add it to your PATH variable.
git clone https://github.com/cymo-eu/kannika-bridge.git
cd kannika-bridge
cargo build --release
# Binary will be in target/release/kbridgeThe restoration comes in 3 steps. Each of these steps can be performed separately and the result can be checked before proceeding to the next step.
graph LR
A[Fetch]-->B[Calculate]-->C[Apply]
-
Fetch - Grabs all committed consumer group offsets from your source cluster and dumps them to CSV.
-
Calculate - Takes a CSV of source offsets and figures out the equivalent offset on the target cluster. It does this by looking for messages that have the source offset stored in a header (offsets differ between clusters, but the header tells us which message is which). Outputs another CSV with the mapped target offsets.
-
Apply - Takes the transformed CSV and commits those offsets to the target cluster so your consumers can resume right where they left off.
- Cluster Migration: Move consumer groups from one Kafka cluster to another
- Disaster Recovery: Restore consumer positions after cluster failures
- Environment Promotion: Sync consumer states between dev/staging/production
- Data Replication: Maintain consumer offset consistency across replicated clusters
- Kafka clusters must be accessible via bootstrap servers and credentials
- Messages on target cluster must contain source offset information in headers (for transformation step) the name of the header is configurable
- Appropriate permissions to read consumer group metadata and commit offsets
# Only process specific topics
kbridge fetch -b localhost:9092 -t topic1 -t topic2 -t topic3# Use custom header key for offset mapping
kbridge calculate -b localhost:9093 -H CustomOffsetHeader -i offsets.csvTo see what offsets would be applied without actually committing them,
use the --dry-run flag.
# Calculate and review target offsets before applying
kbridge fetch -b source:9092 | \
kbridge calculate -b target:9093 -l Offset \
kbridge apply -b target:9093 -i - --dry-runkbridge fetch -b <bootstrap-url> \
-o security.protocol=sasl_ssl \
-o sasl.mechanism=PLAIN \
-o sasl.username=<api-key> \
-o sasl.password=<api-secret> \
-o ssl.ca.location=probekbridge fetch -b <bootstrap-url> \
-o security.protocol=sasl_plaintext \
-o sasl.mechanism=SCRAM-SHA-256 \
-o sasl.username=<username> \
-o sasl.password=<password>kbridge fetch -b <bootstrap-url> \
-o security.protocol=ssl \
-o ssl.ca.location=/path/to/ca-cert \
-o ssl.certificate.location=/path/to/client-cert \
-o ssl.key.location=/path/to/client-key- Ensure the consumer group exists on the target cluster
- Verify you have permissions to read consumer group metadata
- Messages on the target cluster must contain source offset information in headers
- Verify the header key matches what you specified with
-Hflag - Check that your replication process is preserving message headers
- Verify your authentication credentials
- Check that security protocol matches your cluster configuration
- Ensure your user has necessary permissions (read consumer groups, commit offsets)
- Verify bootstrap server addresses are correct and accessible
- Check network connectivity and firewall rules
- Ensure Kafka cluster is running and healthy
By default, kbridge logs at info level with internal Kafka client logs suppressed for cleaner output.
Use -v or --verbose to enable detailed logging including Kafka client internals:
kbridge --verbose fetch -b localhost:9092Override logging via the RUST_LOG environment variable:
# Debug level for all components
RUST_LOG=debug kbridge fetch -b localhost:9092
# Info level with Kafka warnings visible
RUST_LOG=info,rdkafka=warn kbridge fetch -b localhost:9092
# Trace specific modules
RUST_LOG=bridge_core::kafka=trace kbridge fetch -b localhost:9092When RUST_LOG is set, it takes precedence over the --verbose flag.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
# Clone the repository
git clone https://github.com/cymo-eu/kannika-bridge.git
cd kannika-bridge
# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Build the project
cargo build
# Run tests
cargo test
# Run with sample data
cargo run -- fetch -b localhost:9092TODO
