How to back up a RabbitMQ Docker container (2026)

Backing up RabbitMQ safely means one rule: dump, don't copy. `rabbitmqctl export_definitions /tmp/definitions.json` produces a consistent, restorable dump from the running container, which restic then encrypts off-site. exporting definitions captures the full broker topology as JSON, the durable part of RabbitMQ, while the live Mnesia message store is not point-in-time consistent under load. Anything that copies /var/lib/rabbitmq/mnesia live risks an unrestorable backup.

Detection

What Dockstash detects

Env keys detectedRABBITMQ_DEFAULT_USER, RABBITMQ_DEFAULT_PASS, RABBITMQ_DEFAULT_VHOST
Default port5672
Live data paths (never copied live)/var/lib/rabbitmq/mnesia
Example imagesrabbitmq:3.13-management, rabbitmq:3-management, rabbitmq
Commands

The dump command

rabbitmqctl export_definitions /tmp/definitions.json

The restore command

rabbitmqctl import_definitions /tmp/definitions.json

exporting definitions captures the full broker topology as JSON, the durable part of RabbitMQ, while the live Mnesia message store is not point-in-time consistent under load.

The gotchas

Gotchas to avoid

  • Back up broker definitions (topology) via export_definitions — this is the durable, restorable part of RabbitMQ.
  • The Mnesia message store holds in-flight messages and is not safe to copy live; treat persisted messages as transient and rely on producers/consumers to recover.
  • Restoring definitions recreates topology but not the messages that were in queues at backup time.

Do it in one click with Dockstash

Dockstash runs the exact dump above, restics it off-site, and drill-tests the restore automatically — no script to maintain.

Start free All guides

Last updated: July 2026

Frequently asked questions

What part of RabbitMQ should I back up?

The definitions: vhosts, exchanges, queues, bindings, users, and policies. Exporting them as JSON captures your entire broker topology, which is what you actually need to rebuild after a loss.

Can I back up the messages sitting in queues?

Not reliably while the broker runs. The Mnesia store is not point-in-time consistent under load, and messages are meant to be transient. Design consumers to tolerate replay rather than relying on a message backup.

How do I restore a RabbitMQ broker?

Stand up a fresh broker and run rabbitmqctl import_definitions with your exported JSON. The full topology — exchanges, queues, bindings, users, policies — is recreated.

Is copying /var/lib/rabbitmq/mnesia a valid backup?

No. Mnesia is written continuously and a live copy is inconsistent. Export definitions instead; that is the supported, restorable backup path.