Apache Kafka is widely used to move event data between applications, databases, and distributed services. In many systems, Kafka topics contain important business information such as customer transactions, payment events, application logs, and database changes.
Backing up this information is important, but storing only the record value is not always enough. A Kafka record also contains a key, headers, timestamp, partition, offset, and topic information. These details can be essential when an application needs to replay events, investigate an incident, migrate data, or rebuild a development environment.
Confluent Cloud has introduced full-record backup and restore modes for its fully managed Google Cloud Storage and Azure Blob Storage connectors. These modes preserve more than the record value. They capture the key, value, headers, and important Kafka metadata in an envelope that can later be read by a matching source connector.
The two configuration modes are BACKUP_FULL_RECORD for the sink connector and RESTORE_BACKUP_FULL_RECORD for the source connector.
This article explains how these modes work, how to configure a backup and restore workflow, and what developers should understand about record fidelity, schemas, ordering, and recovery limitations.
Why Backing Up Complete Kafka Records Matters
A Kafka record is more than a message payload. It contains several components that work together to describe the event.
Consider a payment event published to a Kafka topic:
Topic: payment-events
Partition: 2
Offset: 10520
Timestamp: 1796292930000
Key: payment-1001
Value:
{
"paymentId": "payment-1001",
"customerId": "customer-1024",
"amount": 2499.00,
"status": "COMPLETED"
}
Headers:
source: mobile-app
event-type: payment-completed
trace-id: trace-abc123
The value contains the business information, but the other fields also matter.
The key can determine how records are distributed across Kafka partitions. Headers may contain tracing information, event types, or application-specific metadata. The timestamp helps consumers understand when the record was created. Partition and offset identify its original position within the topic.
If a backup stores only the value, the restored topic may contain the same business data but not the same complete Kafka records.
This can cause problems when applications depend on keys, headers, timestamps, or original partition ordering.
What can be lost with a traditional backup?
The default GENERIC mode of the object storage connectors is designed to write record values to storage. It does not provide the complete record restoration behavior introduced by the new full-record modes.
Kafka record component | GENERIC mode | Full-record mode |
|---|
Key | Not restored as the original key | Preserved |
Value | Stored as the primary data | Preserved |
Headers | Not restored as original headers | Preserved according to converter fidelity |
Topic | Represented through storage layout and metadata | Stored in the envelope |
Partition | Represented through storage layout | Stored in the envelope |
Offset | Represented through file and path information | Stored in the envelope |
Timestamp | Not restored as the original record timestamp by default | Can be preserved |
Original schemas | May differ after restoration | Backed up and restored with semantic fidelity |
Full-record mode is useful when the objective is to reconstruct Kafka records rather than simply export their values.
Understanding the Full-Record Backup and Restore Architecture
Confluent Cloud uses a matching pair of sink and source connector modes.
The sink connector reads records from Kafka and writes them to object storage. The source connector reads the backup files and produces the records into a destination Kafka topic.
The supported connector pairs are:
Cloud storage | Backup connector | Restore connector |
|---|
Google Cloud Storage | Google Cloud Storage Sink | Google Cloud Storage Source |
Azure Blob Storage | Azure Blob Storage Sink | Azure Blob Storage Source |
The backup and restore modes are:
BACKUP_FULL_RECORD
RESTORE_BACKUP_FULL_RECORD
The workflow looks like this:
Source Kafka Topic
|
v
Object Storage Sink Connector
|
| BACKUP_FULL_RECORD
v
Full-Record Envelope Files
|
v
Google Cloud Storage
or Azure Blob Storage
|
v
Object Storage Source Connector
|
| RESTORE_BACKUP_FULL_RECORD
v
Destination Kafka Topic
During backup, the sink connector wraps each Kafka record in a self-describing envelope. The envelope contains the key, value, headers, topic, partition, offset, timestamp, and relevant schema metadata.
The connector also writes original schema definitions as separate files when using semantic fidelity.
During restoration, the source connector reads the envelope and schema files, reconstructs the original record components, and produces the records to the destination Kafka topic.
The original Schema Registry schemas can also be registered in the destination Schema Registry.
Understanding the Two Connector Modes
Both sink and source connectors have a mode property. Existing connectors use GENERIC by default, so their behavior does not change automatically.
BACKUP_FULL_RECORD
This mode is used by the object storage sink connector.
It captures the complete Kafka record and writes it as an envelope to the configured storage location.
The connector also stores the original Avro or JSON Schema definitions under the _metadata/schemas/ prefix when semantic fidelity is used.
RESTORE_BACKUP_FULL_RECORD
This mode is used by the object storage source connector.
It reads the envelope files, extracts the original record components, and publishes them to Kafka.
The source connector can restore the original key, value, headers, partition, and schema. It can also preserve the original timestamp when the relevant option is enabled.
One important configuration rule is that the mode cannot be changed on an existing connector. If you need to switch from GENERIC to a full-record mode, delete the existing connector and create a new one with a different name and the required mode.
Do not attempt to change the mode of a running source connector. Its stored offset state may cause it to read files in the wrong format.
Preparing the Kafka and Object Storage Resources
Before creating the connectors, prepare the resources required for the backup and restore workflow.
You need:
A Confluent Cloud Kafka cluster.
A source topic containing the records to back up.
A Google Cloud Storage bucket or Azure Blob Storage container.
A sink connector with permission to read the Kafka topic and write to object storage.
A destination Kafka topic for restoration.
A source connector with permission to read object storage and produce to the destination topic.
Schema Registry access when using schema-based formats and semantic fidelity.
The destination topic must have at least as many partitions as the original topic. Otherwise, the restore connector may remain in the RUNNING state without producing records correctly.
For a reliable backup, use a dedicated storage prefix for each backup set. This makes it easier to identify which files belong to a particular backup and prevents accidental replay of unrelated data.
Configuring a Full-Record Backup
Start by creating the appropriate sink connector.
For example, to back up a payment-events topic to Google Cloud Storage:
Open the Confluent Cloud console.
Select the Kafka cluster containing the payment-events topic.
Open Connectors and select Add connector.
Choose Google Cloud Storage Sink or Azure Blob Storage Sink.
Select the payment-events topic.
Configure authentication for Kafka and the destination storage account.
Select the required input and output formats.
Set the connector mode to BACKUP_FULL_RECORD.
Select DefaultPartitioner if the backup will later be restored using the matching source connector.
Review the remaining configuration and create the connector.
The most important settings are the connector mode, record formats, partitioner, and storage location.
A simplified configuration reference looks like this:
mode=BACKUP_FULL_RECORD
partitioner.class=DefaultPartitioner
output.data.format=AVRO
The actual Confluent Cloud configuration interface uses connector-specific fields for selecting formats and storage settings. The snippet illustrates the relevant properties rather than a complete deployable configuration.
Why use DefaultPartitioner?
The backup sink supports DefaultPartitioner, TimeBasedPartitioner, DailyPartitioner, and HourlyPartitioner.
However, the matching full-record source connector restores only backups created with DefaultPartitioner.
DefaultPartitioner creates a separate directory for each Kafka partition. This allows the source connector to identify the original partition and preserve ordering within that partition.
For example, a backup might have a layout similar to:
backup/
topics/
payment-events/
partition=0/
files
partition=1/
files
partition=2/
files
The exact storage layout depends on the connector configuration, but the important point is that the original partition structure must be preserved for full-record restoration.
Do not use TimeBasedPartitioner or another supported sink partitioner if the intention is to restore the backup using RESTORE_BACKUP_FULL_RECORD.
Choosing the Correct Data Fidelity
One of the most important decisions is choosing how closely the restored records must match the original Kafka records.
Confluent provides two fidelity options: Semantic Fidelity and Byte Fidelity.
Semantic Fidelity
Semantic Fidelity is the default approach.
It uses typed converters that understand the record format. Examples include Avro, JSON Schema, JSON, String, and primitive converters.
The connector stores the data in a self-describing format and backs up the original schemas where applicable.
For example, an Avro record can be restored with the same field values and schema definition.
However, semantic equality does not always mean byte-for-byte equality. Formats such as JSON and Avro maps can allow different field or entry ordering. Serialization can therefore produce different bytes even when the restored data represents the same information.
Semantic Fidelity is a good choice when:
Downstream consumers need the original data structure.
Schema Registry integration is required.
Backup files may also be queried by analytics tools.
Exact wire-byte preservation is not mandatory.
Byte Fidelity
Byte Fidelity is intended for situations where the original serialized bytes must remain unchanged.
To enable it, configure the key, value, and header converters to use ByteArrayConverter on both the sink and source connectors.
For example:
key.converter=org.apache.kafka.connect.converters.ByteArrayConverter
value.converter=org.apache.kafka.connect.converters.ByteArrayConverter
header.converter=org.apache.kafka.connect.converters.ByteArrayConverter
The connector treats the data as opaque bytes instead of interpreting its structure.
This supports formats that may not be supported by Schema Registry, including proprietary binary protocols, MessagePack, and Thrift.
The trade-off is that the backup no longer contains the original schema definitions. The connector does not register schemas in the destination Schema Registry during restoration.
If downstream consumers depend on schema IDs, the destination Schema Registry must already contain the required schemas under the same IDs. Schema migration must be handled separately.
Comparing the fidelity options
Feature | Semantic Fidelity | Byte Fidelity |
|---|
Preserves field values | Yes | Yes, as original bytes |
Exact wire-byte preservation | Not guaranteed | Yes |
Original schema backup | Supported for applicable converters | Not supported |
Schema Registry integration | Supported | Bypassed |
Analytics-friendly backup files | Yes | No, payloads are opaque |
Proprietary binary formats | Limited by converter support | Supported |
Operational complexity | Lower | Higher |
Use Semantic Fidelity when readable, structured backups and schema restoration are important. Choose Byte Fidelity when exact serialized bytes are the primary requirement.
One important limitation is that ProtobufConverter is not currently supported in these full-record modes. Do not assume that selecting a Protobuf format in the connector interface makes it compatible with full-record backup and restore.
Restoring Kafka Records From Object Storage
Once the backup connector has written the envelope files and required schema files, you can create the source connector.
For example, assume the original topic is payment-events and the backup is stored in Google Cloud Storage.
The restore process is:
Create the destination Kafka topic.
Ensure it has at least as many partitions as the original topic.
Open the Confluent Cloud console.
Select Add connector.
Choose Google Cloud Storage Source or Azure Blob Storage Source.
Configure access to the backup location.
Set the connector mode to RESTORE_BACKUP_FULL_RECORD.
Select the same envelope file format used by the sink connector.
Configure the key, value, and header converters to match the backup.
Configure the destination Kafka cluster and topic settings.
Review timestamp and compression settings.
Create the connector and monitor its status.
A simplified source configuration looks like this:
mode=RESTORE_BACKUP_FULL_RECORD
input.data.format=AVRO
restore.topic.prefix=restored-
restore.preserve.timestamps=false
The source connector reads the envelope files and reconstructs the records.
With the topic prefix configured, the restored topic can be named restored-payment-events instead of payment-events.
This is useful when testing a backup without writing into the original production topic.
Preserve original timestamps when required
The restore.preserve.timestamps property determines whether restored records retain their original Kafka producer timestamps.
When set to false, which is the default, the source connector assigns the current restore time.
When set to true, the connector uses the original timestamps stored in the backup.
This distinction matters because Kafka retention policies can delete old records.
Suppose a backup contains records from six months ago, but the destination topic has a retention period of seven days. If the original timestamps are restored, Kafka may consider those records expired and remove them almost immediately.
Before enabling timestamp preservation, review the destination topic's retention.ms and retention.bytes settings.
Possible approaches include:
Temporarily disabling time-based retention by setting retention.ms to -1.
Increasing retention to cover the age of the backup and the required processing period.
Leaving timestamp preservation disabled when the restored stream should behave like a newly created stream.
After downstream applications have processed the restored data, you can return the topic to its normal retention settings if appropriate.
Understanding Schema Restoration
Schema handling is important when Kafka topics use Avro or JSON Schema.
With Semantic Fidelity, the sink connector stores the original schema definitions separately from the envelope data.
During restoration, the source connector registers the schemas in the destination Schema Registry.
The schema definition can be preserved, including field names, types, structure, documentation, and default values.
However, the destination Schema Registry assigns its own schema IDs and version numbers as schemas are registered. These IDs are not necessarily the same as the source IDs.
Consumers that resolve schemas by subject name are generally better positioned for this migration than consumers that rely on hard-coded schema IDs.
Match the subject naming strategy
Schema Registry supports different subject naming strategies. The common options are:
Strategy | Example subject |
|---|
TopicNameStrategy | payment-events-value |
RecordNameStrategy | com.example.Payment |
TopicRecordNameStrategy | payment-events-com.example.Payment |
The source connector must use a subject naming strategy compatible with the original producer.
If the strategies do not match, the connector may register schemas under unexpected subjects without reporting the mismatch as an error.
Also remember that schema backup does not include every Schema Registry governance feature. Encryption keys, client-side field-level encryption rules, schema metadata, and migration rules need separate handling.
For a production migration, review the destination Schema Registry compatibility settings before restoring data containing multiple schema versions.
Preserving Kafka Headers Correctly
Kafka headers are often used for tracing, routing, event classification, and application metadata.
The header.converter determines how headers are serialized and restored.
The default SimpleHeaderConverter is suitable for plain UTF-8 text and simple primitive values. However, it may change some header values during a round trip.
For example:
Non-UTF-8 binary values may be corrupted during text conversion.
High-precision floating-point values may lose precision.
JSON-like values may be converted into compact text.
Map, array, and structure headers may be restored as strings.
If the application depends on exact header bytes, use ByteArrayConverter for headers on both the sink and source connectors.
This means restored headers are represented as bytes, so downstream consumers must deserialize them as needed.
Do not assume that preserving the header name automatically guarantees preservation of its original value representation. The converter configuration determines the result.
Delivery Semantics and Record Ordering
A backup process is only useful if it can recover records reliably.
The sink and source connectors have different delivery guarantees.
Operation | Delivery behavior |
|---|
Full-record backup | Exactly-once behavior when using a deterministic partitioner such as DefaultPartitioner |
Full-record restore | At-least-once |
During backup, the sink connector uses upload sequence information to avoid duplicate envelope files when a task fails and restarts.
During restoration, a failure and restart can cause records to be produced again. This means the source connector provides at-least-once behavior rather than an exactly-once restoration guarantee.
Downstream consumers should therefore be idempotent or prepared to handle duplicates.
For example, a payment-processing consumer should not execute a payment twice simply because the same event is received again. Use an event identifier or another reliable deduplication mechanism.
Understanding file rotation
The sink connector uses file rotation settings to determine how records are grouped into object storage files.
Important settings include:
These settings influence file size and the time span represented by each file.
The source connector reads complete files, so file rotation also determines the smallest practical unit of replay.
Smaller files provide more granular replay but create more objects to manage. Larger files reduce object counts but make selective restoration less flexible.
For example, if a backup file contains an entire hour of records, you cannot ask the source connector to restore only the first ten minutes from that file through an offset or timestamp filter.
Choose file sizes according to the expected restore workload, storage costs, and operational requirements.
Important Limitations to Consider
Full-record backup and restore provides more control than a value-only export, but it is not a replacement for every Kafka replication or disaster recovery solution.
It is not a replacement for Cluster Linking
Confluent recommends Cluster Linking for low-latency replication, offset preservation, active-passive failover, and real-time multi-cluster disaster recovery.
Object storage backup and restore is better suited to long-term archival, cold storage, cross-environment data seeding, compliance archives, and replay after Kafka retention has expired.
The source connector reads the configured storage prefix
The restore connector reads every file under the configured topics.dir prefix.
It cannot directly select files using an offset range, timestamp range, or filename pattern.
If you need to restore only a subset of a backup, copy the required files to a separate storage prefix and point the source connector at that location.
Keep each backup generation isolated to avoid accidentally replaying multiple backups into the same destination topic.
Match converters and storage formats
A source connector uses one set of converters and one storage format for the files under its configured prefix.
If the directory contains backups created with different converters or formats, restoration can fail.
For example, a directory containing both Avro-based and ByteArrayConverter-based backups should not be restored using one source connector with a single converter configuration.
Use separate prefixes and source connectors for different converter and format combinations.
Do not mix unsupported partitioner layouts
The sink supports several partitioners in full-record backup mode, but the source connector restores only backups written with DefaultPartitioner.
This is an important design decision to make before creating the backup.
Best Practices for Production Backups
A reliable backup strategy needs more than a working sink connector. It should also account for restoration, permissions, schema compatibility, and failure handling.
Consider these practices:
Use BACKUP_FULL_RECORD when the recovery requirement includes keys, values, headers, and record metadata.
Use DefaultPartitioner for backups that must be restored with the matching full-record source connector.
Choose Semantic Fidelity or Byte Fidelity based on whether readable schemas or exact serialized bytes are more important.
Keep separate storage prefixes for different backup generations and converter configurations.
Store a backup manifest containing topic names, formats, converter settings, schema strategies, and creation details.
Use fail-fast error handling so serialization or storage errors do not silently create incomplete backups.
Test restoration regularly rather than assuming that successful uploads guarantee successful recovery.
Review destination topic partition counts before starting a restore.
Check retention settings before preserving original timestamps.
Make downstream consumers idempotent because restoration provides at-least-once delivery.
Configure compression on the restore producer when the original stream used compression and storage efficiency matters.
Keep schema compatibility settings aligned with the versions being restored.
For a backup intended to be complete, avoid silently ignoring records that cannot be serialized or written. A dead-letter queue may preserve operational continuity, but records sent to a separate queue are not part of the object storage backup unless they are backed up independently.
When Should You Use Full-Record Backup and Restore?
The feature is particularly useful in situations where Kafka data needs to be preserved beyond the normal topic retention period.
Scenario | How full-record backup helps |
|---|
Long-term archival | Stores Kafka records in object storage for later replay |
Development environment setup | Restores production-like events into a separate environment |
Compliance and audit | Preserves record components and metadata for review |
Schema Registry migration | Recreates supported original schemas in another registry |
Cold storage recovery | Replays records after the original Kafka retention period expires |
Cross-cloud migration | Moves supported backups between Google Cloud Storage and Azure Blob Storage workflows |
The feature should not be selected solely because an application needs real-time replication. In that situation, Cluster Linking or another dedicated replication solution may be more appropriate.
Conclusion
Confluent Cloud's full-record backup and restore modes provide a more complete way to archive and recover Kafka data using managed object storage connectors.
BACKUP_FULL_RECORD captures the key, value, headers, and important Kafka metadata in an envelope. RESTORE_BACKUP_FULL_RECORD reads that envelope and reconstructs the records in a destination Kafka topic.
The two fidelity options address different requirements. Semantic Fidelity preserves structured data and supports schema backup, while Byte Fidelity preserves the exact serialized bytes when configured with ByteArrayConverter.
For successful restoration, developers must pay attention to the partitioner, converter settings, storage layout, destination topic partition count, schema compatibility, and retention configuration. They should also account for at-least-once delivery during restoration.
The most important step is to test the complete backup and restore process before relying on it for production recovery. A backup is only valuable when the team can restore it correctly and verify that the recovered Kafka records meet the application's requirements.
Apache KafkaConfluent CloudKafka backup and restoreGoogle Cloud Storage connectorAzure Blob Storage connectorKafka record metadataSchema Registry
Join the conversation! Your thoughts help the community grow.