Migrate data to a new RabbitMQ service instance
In this article you learn how to migrate your queue definitions from an existing RabbitMQ service instance to a newly created one.
Requirements
Section titled “Requirements”catopensslgunzipnodejs(minimum version:6.11.0)python(minimum version2.7.9)restore_queues.jsrabbitmqadmin
Migration steps
Section titled “Migration steps”-
Order and configure a new target service instance Order a new service instance with the same plan and configuration as your existing service. Create a credential key for it. Read Create and manage RabbitMQ services and Create and manage RabbitMQ credentials on how to achieve this task.
-
Trigger a manual backup of your source service instance Open the service dashboard to manually trigger a backup of your source service instance. Please make sure you set an encryption password. You can find instructions on how to do that in Backup and restore your RabbitMQ services.
-
Download and prepare the backup Download the latest backup of source service instance from Service Dashboard and store it on your local machine.
Use following commands to decrypt and decompress the backup file:
Terminal window cat [downloaded_backup_filename] | openssl enc -aes256 -md md5 -d -pass 'pass:[your_backup_encryption_password]' | gunzip -c > backup_settings.jsonExample:
Terminal window cat 4332fced-9984-4ffa-8f63-0c872d518109-1655429318631 | openssl enc -aes256 -md md5 -d -pass 'pass:mypassword' | gunzip -c > backup_settings.json -
Download, prepare and execute the required scripts Download the needed restore script from Github.
-
Visit the
a9s-messaging-restoreGithub page and download the scriptVisit a9s-messaging-restore on Github and download the file
restore_queues.jsinto your working directory. -
Make it executable
Terminal window chmod +x restore_queues.js -
Download
rabbitmqadminOpen the RabbitMQ management dashboard of either your old or new instance and download therabbitmqadminCLI tool. You can download it with adding cli to the managment URL:https://[hostname]:[port]/cli. This guide assumes, that you store the files in theDownload-folder of your home directory. -
Restore the backup to target instance Get the
hostname,port,usernameandpasswordof the target instance. Read Create and manage RabbitMQ services and Create and manage RabbitMQ credentials on how to achieve this task. Then execute the script:Terminal window ./restore_queues.js $(which python) ~/Downloads/rabbitmqadmin [target_host] [target_port] [target_username] [target_password] ./backup_settings.jsonExample:
Terminal window ./restore_queues.js $(which python3) ./rabbitmqadmin.py rad741cc2-1.data.eu01.onstackit.cloud 49374 a9s-brk-usr-73c13bd10f7a593e40d40351502b0e3b5191112d a9sb99f0aad4f580691fd0667013ce5634afd3ef261 ./backup_settings.json -
Verify the restored data Connect to the RabbitMQ management dashboard of the target instance and check restored queue definitions.
For additional information visit the AnyNines documentation.