How to Backup and Restore RabbitMQ Data & Configurations
How to Backup and Restore RabbitMQ Data & Configurations
Configurations
https://computingforgeeks.com/how-to-backup-and-restore-rabbitmq-data-configurations/[01/02/2019 22:13:17]
How to Backup and Restore RabbitMQ Data & Configurations - Computingforgeeks
In this post, I’ll like us to look at how to perform a backup for RabbitMQ configurations
and data. This will also include information on restoring a RabbitMQ backup into a new
deployment.
$ rabbitmqctl cluster_status
Cluster status of node rabbit@computingforgeeks-centos7 ...
[{nodes,[{disc,['rabbit@computingforgeeks-centos7']}]},
{running_nodes,['rabbit@computingforgeeks-centos7']},
{cluster_name,<<"rabbit@computingforgeeks-centos7">>},
{partitions,[]},
{alarms,[{'rabbit@computingforgeeks-centos7',[]}]}]
Please note this backup doesn’t include Messages since they are stored in a separate
message store. It will only backup RabbitMQ users, vhosts, queues, exchanges,
and bindings . The backup file is a JSON representation of RabbitMQ metadata. We will
do a backup using rabbitmqadmin command line tool.
The management plugin ships with a command line tool rabbitmqadmin. You need to
enable the management plugin:
This plugin is used to perform some of the same actions as the Web-based UI, and which
may be more convenient for automation tasks.
Download rabbitmqadmin
https://computingforgeeks.com/how-to-backup-and-restore-rabbitmq-data-configurations/[01/02/2019 22:13:17]
How to Backup and Restore RabbitMQ Data & Configurations - Computingforgeeks
http://{node-hostname}:15672/cli/
Once downloaded, make the file executable and move it to /usr/local/bin directory:
chmod +x rabbitmqadmin
sudo mv rabbitmqadmin /usr/local/bin
Example:
If you ever want to restore your RabbitMQ configurations from a backup, use the
command:
Example
RabbitMQ Definitions and Messages are stored in an internal database located in the
node’s data directory. To get the directory path, run the following command against a
running RabbitMQ node:
https://computingforgeeks.com/how-to-backup-and-restore-rabbitmq-data-configurations/[01/02/2019 22:13:17]
How to Backup and Restore RabbitMQ Data & Configurations - Computingforgeeks
Sample output:
"/var/lib/rabbitmq/mnesia/rabbit@computingforgeeks-server1"
# ls /var/lib/rabbitmq/mnesia/rabbit@computingforgeeks-centos7
cluster_nodes.config nodes_running_at_shutdown
rabbit_durable_route.DCD rabbit_user.DCD schema.DAT
DECISION_TAB.LOG rabbit_durable_exchange.DCD
rabbit_runtime_parameters.DCD rabbit_user_permission.DCD
schema_version
LATEST.LOG rabbit_durable_exchange.DCL rabbit_serial
rabbit_vhost.DCD
msg_stores rabbit_durable_queue.DCD
rabbit_topic_permission.DCD rabbit_vhost.DCL
In RabbitMQ versions starting with 3.7.0 all messages data is combined in the
msg_stores/vhosts directory and stored in a subdirectory per vhost. Each vhost directory
is named with a hash and contains a .vhost file with the vhost name, so a specific vhost’s
message set can be backed up separately.
To do RabbitMQ definitions and messages data backup, copy or archive this directory
and its contents. But first, you need to stop RabbitMQ service
https://computingforgeeks.com/how-to-backup-and-restore-rabbitmq-data-configurations/[01/02/2019 22:13:17]
How to Backup and Restore RabbitMQ Data & Configurations - Computingforgeeks
To restore from Backup, extract the files from backup to the data directory.
Internal node database stores node’s name in certain records. Should node name
change, the database must first be updated to reflect the change using the following
rabbitmqctl command:
When a new node starts with a backed up directory and a matching node name, it
should perform the upgrade steps as needed and proceed to boot.