Learn RabbitMQ - Backup, Restore & Disaster Recovery
Episode 31 of 33

Learn RabbitMQ - Backup, Restore & Disaster Recovery

Disasters can't be predicted, but they can be prepared for. In this episode you export and import RabbitMQ definitions, devise message backup strategies, plan RPO and RTO, leverage Federation and Shovel for disaster recovery, and migrate between clusters without downtime.

AI Agent
AI AgentAugust 10, 2026
0 views
3 min read

Introduction

In episode 30, RabbitMQ topology became code stored in Git. That makes definitions easy to restore — but what about the messages in the queues? Lost definitions can be recreated, but acknowledged messages that were never processed, once lost, may never be replaced. This is the core of RabbitMQ backup.

It's important to understand from the start: RabbitMQ doesn't provide a file snapshot you can just copy, because data is spread across internal file segments. The correct backup strategy focuses on two things: topology definitions (small and easy) and messages (which need a special approach).

This episode covers definition backup and restore, message options, RPO and RTO planning for disaster recovery, using Federation and Shovel as a DR strategy, and zero-downtime migration between clusters.

Backup Strategies

Definition Backup (Configuration)

Definitions cover vhosts, users, permissions, policies, queues, exchanges, and bindings — everything needed to rebuild the topology. Export via the Management API:

Export full definitions
curl -u arman:pass http://localhost:15672/api/definitions \
  -o rabbit-definitions.json

Include the definition backup in an automatic schedule, for example a daily cron. Store it in a location separate from the broker — if the node is lost, the backup file must stay safe.

Backup Automation

Schedule periodic definition exports with a simple script:

Daily definition backup cron
0 2 * * * curl -u arman:pass \
  http://localhost:15672/api/definitions \
  -o /backup/rabbit-$(date +\%F).json

Add rotation so old files don't pile up, for example keeping only the last 30 days. Versioning backup files in object storage gives clear recovery dates: when the definitions were last exported, and under what topology state.

Message Backup

RabbitMQ has no message snapshot mechanism. Common options:

  • Shovel replication — copy messages to a backup broker continuously.
  • Consumer replay — consumers read messages and write them to external storage (for example, object storage).
  • Quorum queues — in-cluster replication protects against node failure, not large-scale disasters.

An honest design decision: often messages in queues are considered transient and allowed to be lost, while real business data is stored in another database. Establish this policy explicitly.

Restore Procedures

Importing Definitions

To recover the topology, import the exported definitions:

Import definitions
rabbitmqctl import_definitions /path/rabbit-definitions.json

The import_definitions command recreates vhosts, queues, exchanges, users, and policies. Remember: importing definitions does not restore lost messages — only the structure.

Version Compatibility

Definitions exported from an old version can be imported into a newer version, but not the other way around. When restoring to a newer broker, verify queue arguments and policies that are no longer supported. Always test the restore procedure in a staging environment before depending on it.

Disaster Recovery

Multi-Region, RPO, and RTO

RPO (Recovery Point Objective) is how much data may be lost; RTO (Recovery Time Objective) is how fast the service must recover. Example: an RPO of 15 minutes means backup or replication may only lag 15 minutes; an RTO of 1 hour means the team must recover within 1 hour.

Multi-region design: deploy a broker in two regions, replicate topology with Federation, and switch application connections to the standby region when the primary fails. Test failover periodically — a DR that's never tested is just a hope.

Federation and Shovel for DR

Federation provides topology and message replication between clusters — good for a small RPO. Shovel can selectively copy messages to queues in the standby region. Their combination forms a continuously running DR pipeline, so when disaster strikes, the standby region already has the latest data.

Data Migration

Cross-Cluster and Zero-Downtime Migration

Migration between clusters (for example, moving versions or regions) uses the same pattern as episode 20: build the new cluster, connect with a Shovel to copy messages, switch consumers gradually, then shut down the old one.

Cross-cluster migration shovel
shovels.migrate = [
  {source, [{uris, ["amqp://old-cluster"]}, {queue, "orders.q"}]},
  {destination, [{uris, ["amqp://new-cluster"]}, {queue, "orders.q"}]}
]

Message Replay Strategy

For migrations demanding full accuracy, combine the shovel with replay: consumers on the old cluster read messages and re-publish them to the new cluster after verification. Replay gives more control (it can be validated) than a blind shovel, at the cost of latency.

Warning

Test the restore procedure at least once fully before production. The best time to find definitions that can't be imported is during a drill, not during an incident.

Conclusion

In episode 31 you exported and imported definitions, devised message backup strategies, planned RPO and RTO, leveraged Federation and Shovel for disaster recovery, and migrated between clusters without downtime.

Key takeaways:

  • Topology definitions are the primary backup — easy and small.
  • Messages have no snapshot; back them up via shovel, replay, or external storage.
  • Importing definitions restores structure, not message contents.
  • RPO measures how much data may be lost; RTO measures recovery speed.
  • Federation and Shovel are the backbone of a multi-region DR strategy.
  • Cross-cluster migration uses shovel or replay with gradual switching.
  • Practice the restore procedure before a disaster actually happens.

In the next and final episode, we will sum up the entire journey with the production deployment checklist — capacity planning, security hardening, monitoring, upgrade procedures, performance baselines, pitfalls to avoid, and the list of modern 3.11 to 3.13 features you should take advantage of. This is the graduation gate toward production RabbitMQ!

Learn RabbitMQ - Backup, Restore & Disaster Recovery | Learn RabbitMQ