Skip to main content

CLI Reference

Complete reference documentation for all OSO Kafka Backup CLI commands.

Global Options

These options apply to all commands:

kafka-backup [OPTIONS] <COMMAND>
OptionDescription
-v, --verboseEnable verbose logging. Use -v for debug, -vv for trace
-h, --helpPrint help information
-V, --versionPrint version information

backup

Run a backup operation from a Kafka cluster to storage.

kafka-backup backup --config <PATH>

Options

FlagTypeRequiredDescription
-c, --configPATHYesPath to backup configuration YAML

Examples

# Basic backup
kafka-backup backup --config backup.yaml

# With debug logging
kafka-backup -v backup --config /etc/kafka-backup/production.yaml

# With trace logging
kafka-backup -vv backup --config backup.yaml

Exit Codes

CodeMeaning
0Backup completed successfully
1Backup failed

restore

Restore data from a backup to a Kafka cluster.

kafka-backup restore --config <PATH>

Options

FlagTypeRequiredDescription
-c, --configPATHYesPath to restore configuration YAML

Examples

# Basic restore
kafka-backup restore --config restore.yaml

# Restore with verbose output
kafka-backup -v restore --config dr-restore.yaml

list

List available backups or show details of a specific backup.

kafka-backup list --path <PATH> [--backup-id <ID>]

Options

FlagTypeRequiredDescription
-p, --pathPATHYesPath to storage location (local path or S3 URI)
-b, --backup-idSTRINGNoSpecific backup ID to show details for

Examples

# List all backups in local storage
kafka-backup list --path /var/lib/kafka-backup/data

# List backups in S3
kafka-backup list --path s3://my-bucket/backups

# Show details for a specific backup
kafka-backup list --path /data --backup-id daily-backup-001

Output

Available Backups:
─────────────────────────────────────────────────────────────
daily-backup-001
Created: 2024-12-03T02:00:00Z
Topics: 5
Records: 1,234,567
Size: 128 MB (compressed)
─────────────────────────────────────────────────────────────

status

Show status and statistics of a backup job.

kafka-backup status --path <PATH> --backup-id <ID> [--db-path <PATH>]

Options

FlagTypeRequiredDescription
-p, --pathPATHYesPath to storage location
-b, --backup-idSTRINGYesBackup ID to show status for
--db-pathPATHNoPath to offset database (for tracking progress)

Examples

kafka-backup status --path /data --backup-id backup-001

kafka-backup status -p /data -b backup-001 --db-path /var/lib/kafka-backup/offsets.db

Output Information

  • Manifest information (created date, source cluster)
  • Topic/partition/segment counts
  • Record and size statistics (compressed and uncompressed)
  • Compression ratio
  • Offset tracking status per partition

describe

Show detailed backup manifest information.

kafka-backup describe --path <PATH> --backup-id <ID> [--format <FORMAT>]

Options

FlagTypeRequiredDefaultDescription
-p, --pathPATHYes-Path to storage location
-b, --backup-idSTRINGYes-Backup ID to describe
-f, --formatSTRINGNotextOutput format: text, json, yaml

Examples

# Human-readable output
kafka-backup describe --path /data --backup-id backup-001

# JSON for scripting
kafka-backup describe -p /data -b backup-001 --format json

# YAML output
kafka-backup describe -p /data -b backup-001 -f yaml

Output Information

  • Backup ID and creation timestamp
  • Source cluster ID and brokers
  • Compression algorithm
  • Topic/partition/segment/record counts
  • Compressed and uncompressed sizes
  • Compression ratio
  • Time range of backed-up data
  • Per-topic and per-partition details

validate

Validate backup integrity.

kafka-backup validate --path <PATH> --backup-id <ID> [--deep]

Options

FlagTypeRequiredDefaultDescription
-p, --pathPATHYes-Path to storage location
-b, --backup-idSTRINGYes-Backup ID to validate
--deepBOOLNofalsePerform deep validation (read and verify each segment)

Examples

# Shallow validation (quick - checks existence and metadata)
kafka-backup validate --path /data --backup-id backup-001

# Deep validation (thorough - reads and parses all segments)
kafka-backup validate -p /data -b backup-001 --deep

Validation Report

Validation Report: backup-001
════════════════════════════════════════════════════════════

Segments:
Checked: 156
Valid: 156
Missing: 0
Corrupted: 0

Records Validated: 2,456,789

Issues Found: 0

Result: ✓ VALID

validate-restore

Validate a restore configuration without executing it.

kafka-backup validate-restore --config <PATH> [--format <FORMAT>]

Options

FlagTypeRequiredDefaultDescription
-c, --configPATHYes-Path to restore configuration file
-f, --formatSTRINGNotextOutput format: text, json, yaml

Examples

# Validate restore config
kafka-backup validate-restore --config restore.yaml

# Get JSON report for CI/CD
kafka-backup validate-restore -c restore.yaml --format json

Report Contents

  • Restore status (VALID or INVALID)
  • Topics to restore (count and names)
  • Segments to process
  • Records and bytes to restore
  • Time range of restore
  • Consumer offset actions
  • Errors and warnings

show-offset-mapping

Show offset mapping for a backup.

kafka-backup show-offset-mapping --path <PATH> --backup-id <ID> [--format <FORMAT>]

Options

FlagTypeRequiredDefaultDescription
-p, --pathPATHYes-Path to storage location
-b, --backup-idSTRINGYes-Backup ID to show offset mapping for
-f, --formatSTRINGNotextOutput: text, json, yaml, csv

Examples

# Human-readable output
kafka-backup show-offset-mapping --path /data --backup-id backup-001

# CSV for spreadsheets
kafka-backup show-offset-mapping -p /data -b backup-001 --format csv

# JSON for programmatic use
kafka-backup show-offset-mapping -p /data -b backup-001 -f json

Output

Offset Mapping: backup-001
─────────────────────────────────────────────────────────────
Topic Partition Source Start Source End Records
─────────────────────────────────────────────────────────────
orders 0 0 150233 150234
orders 1 0 148891 148892
orders 2 0 152456 152457
payments 0 0 78234 78235
...

To reset consumer groups, use:
kafka-consumer-groups --bootstrap-server <broker> \
--group <group-name> --topic orders:0 \
--reset-offsets --to-offset 150233 --execute

offset-reset

Generate or execute consumer group offset reset plans.

offset-reset plan

Generate an offset reset plan from backup's offset mapping.

kafka-backup offset-reset plan \
--path <PATH> \
--backup-id <ID> \
--groups <GROUPS> \
--bootstrap-servers <SERVERS> \
[--format <FORMAT>] \
[--dry-run <BOOL>]

Options

FlagTypeRequiredDefaultDescription
-p, --pathPATHYes-Path to storage location
-b, --backup-idSTRINGYes-Backup ID with offset mapping
-g, --groupsSTRINGYes-Consumer groups (comma-separated)
--bootstrap-serversSTRINGYes-Kafka bootstrap servers
-f, --formatSTRINGNotextOutput: text, json, csv, shell-script
--dry-runBOOLNotruePreview only, no changes

Examples

kafka-backup offset-reset plan \
--path /data \
--backup-id backup-001 \
--groups my-group,another-group \
--bootstrap-servers localhost:9092

# Generate shell script
kafka-backup offset-reset plan \
-p /data -b backup-001 \
-g consumer-group \
--bootstrap-servers broker-1:9092 \
--format shell-script

offset-reset execute

Execute an offset reset plan.

kafka-backup offset-reset execute \
--path <PATH> \
--backup-id <ID> \
--groups <GROUPS> \
--bootstrap-servers <SERVERS> \
[--security-protocol <PROTOCOL>]

Options

FlagTypeRequiredDefaultDescription
-p, --pathPATHYes-Path to storage location
-b, --backup-idSTRINGYes-Backup ID
-g, --groupsSTRINGYes-Consumer groups
--bootstrap-serversSTRINGYes-Kafka bootstrap servers
--security-protocolSTRINGNoPLAINTEXTSecurity: PLAINTEXT, SSL, SASL_SSL, SASL_PLAINTEXT

Examples

kafka-backup offset-reset execute \
--path /data \
--backup-id backup-001 \
--groups my-group \
--bootstrap-servers localhost:9092

# With SSL
kafka-backup offset-reset execute \
-p /data -b backup-001 \
-g consumer-group \
--bootstrap-servers broker-1:9092 \
--security-protocol SSL

offset-reset script

Generate a shell script for manual offset reset.

kafka-backup offset-reset script \
--path <PATH> \
--backup-id <ID> \
--groups <GROUPS> \
--bootstrap-servers <SERVERS> \
[--output <PATH>]

Options

FlagTypeRequiredDefaultDescription
-o, --outputPATHNostdoutOutput file path

offset-reset-bulk

Execute bulk parallel offset reset (optimized for large consumer groups).

kafka-backup offset-reset-bulk \
--path <PATH> \
--backup-id <ID> \
--groups <GROUPS> \
--bootstrap-servers <SERVERS> \
[OPTIONS]

Options

FlagTypeRequiredDefaultDescription
-p, --pathPATHYes-Path to storage location
-b, --backup-idSTRINGYes-Backup ID
-g, --groupsSTRINGYes-Consumer groups (comma-separated)
--bootstrap-serversSTRINGYes-Kafka bootstrap servers
--max-concurrentINTNo50Maximum concurrent requests
--max-retriesINTNo3Maximum retry attempts
--security-protocolSTRINGNoPLAINTEXTSecurity protocol
-f, --formatSTRINGNotextOutput: text, json

Examples

kafka-backup offset-reset-bulk \
--path /data \
--backup-id backup-001 \
--groups group1,group2 \
--bootstrap-servers broker-1:9092,broker-2:9092 \
--max-concurrent 100

# With metrics output
kafka-backup offset-reset-bulk \
-p /data -b backup-001 \
-g my-group \
--bootstrap-servers localhost:9092 \
--format json

Performance

  • ~50x faster than sequential offset reset
  • Per-partition retry with exponential backoff
  • Detailed metrics (p50/p99 latency, throughput)
  • Progress reporting

offset-rollback

Snapshot and rollback consumer group offsets.

offset-rollback snapshot

Create a snapshot of current consumer group offsets.

kafka-backup offset-rollback snapshot \
--path <PATH> \
--groups <GROUPS> \
--bootstrap-servers <SERVERS> \
[--description <DESC>]

Options

FlagTypeRequiredDescription
-p, --pathPATHYesPath to store snapshots
-g, --groupsSTRINGYesConsumer groups
--bootstrap-serversSTRINGYesKafka bootstrap servers
-d, --descriptionSTRINGNoSnapshot description
--security-protocolSTRINGNoSecurity protocol
-f, --formatSTRINGNoOutput: text, json

Example

kafka-backup offset-rollback snapshot \
--path /data/snapshots \
--groups my-group \
--bootstrap-servers localhost:9092 \
--description "Before maintenance"

offset-rollback list

List available offset snapshots.

kafka-backup offset-rollback list --path <PATH>

offset-rollback show

Show details of a specific snapshot.

kafka-backup offset-rollback show \
--path <PATH> \
--snapshot-id <ID>

offset-rollback rollback

Rollback offsets to a previous snapshot.

kafka-backup offset-rollback rollback \
--path <PATH> \
--snapshot-id <ID> \
--bootstrap-servers <SERVERS> \
[--verify <BOOL>]

Options

FlagTypeRequiredDefaultDescription
--verifyBOOLNotrueVerify offsets after rollback

offset-rollback verify

Verify current offsets match a snapshot.

kafka-backup offset-rollback verify \
--path <PATH> \
--snapshot-id <ID> \
--bootstrap-servers <SERVERS>

offset-rollback delete

Delete a snapshot.

kafka-backup offset-rollback delete \
--path <PATH> \
--snapshot-id <ID>

three-phase-restore

Run complete three-phase restore with automatic offset reset.

kafka-backup three-phase-restore --config <PATH>

Options

FlagTypeRequiredDescription
-c, --configPATHYesPath to configuration file

What It Does

  1. Phase 1: Collect offset headers from source backup
  2. Phase 2: Restore data to target cluster
  3. Phase 3: Reset consumer group offsets

Example

kafka-backup three-phase-restore --config dr-restore.yaml

Output

Three-Phase Restore Report
════════════════════════════════════════════════════════════

Backup ID: production-backup-001
Status: ✓ SUCCESS

Phase 2 - Data Restore:
Records Restored: 2,456,789
Topics: 4
Duration: 8m 23s

Phase 3 - Offset Reset:
Strategy: header-based
Consumer Groups: 3
Partitions Reset: 33

Warnings: 0

Environment Variables

The CLI respects these environment variables:

VariableDescription
KAFKA_BACKUP_CONFIGDefault config file path
RUST_LOGLogging level (e.g., info, debug, trace)
AWS_ACCESS_KEY_IDAWS access key for S3
AWS_SECRET_ACCESS_KEYAWS secret key for S3
AWS_REGIONAWS region for S3
AZURE_STORAGE_ACCOUNTAzure storage account name
AZURE_STORAGE_KEYAzure storage account key
GOOGLE_APPLICATION_CREDENTIALSPath to GCP service account JSON