Programster's Blog

Tutorials focusing on Linux, programming, and open-source

RabbitMQ - Export / Import Configuration

If you are deploying a fresh RabbitMQ instance, you may wish to have an easy way to export the configuration from the old instance and import into the new instance. Luckily RabbitMQ has an API, so this can be done fairly easily with the commands outlined below:

This tutorial assumes you are using plain HTTP and that you have mapped the web management interface ports to 80/443, but you should be able to easily adjust if you are using HTTPS and/or you have not re-mapped the default ports.

Export

Update the variables as appropriate before then running the curl command:

USERNAME="admin"
PASSWORD="myPasswordHere"
URL=http://rabbitmq.mydomain.com/api/definitions

curl --silent -u $USERNAME:$PASSWORD $URL -o config.json

After running the command you will just have the generated config.json file. There will be no output from having run the command.

Import

Update the variables as appropriate before then running the curl command:

USERNAME="admin"
PASSWORD="myPasswordHere"
URL=http://rabbitmq.mydomain.com/api/definitions

curl \
  -H 'Content-Type: application/json' \
  -X POST \
  -u $USERNAME:$PASSWORD \
  -d "@config.json" \
  $URL
Last updated: 7th May 2024
First published: 7th May 2024