Skip to content

Allow Restore to different UUID #21

@alanbach

Description

@alanbach

I know this is currently not supported, but it will be extremely useful to be able to perform restores to controllers with different UUIDs or at least to be able to deploy new controllers with a supplied UUID.

This makes this very important in disaster recovery situations where you have to re-deploy your juju controllers and naturally they have a different UUID than your backup.

You may have to be able to hack your way in, but it is very cumbersome. When restoring to a new controller, you will get:

ERROR precheck: controller model uuids don't match - backup: "c6d7b3b0-4cd8-4678-80d7-a05def24ffb1", controller: "49153454-6367-447e-8b45-9c1d72fad421"

I used these above UUIDs for the sample process below.

What to do?

  1. While in the newly deployed controller, backup current juju DB:
$ export user=$(sudo grep tag /var/lib/juju/agents/machine-*/agent.conf | cut -d' ' -f2)
$ export password=$(sudo grep statepassword /var/lib/juju/agents/machine-*/agent.conf | cut -d' ' -f2)
$ sudo /snap/juju-db/current/bin/mongodump -h 127.0.0.1 --port 37017 --ssl -u "${user}" -p "${password}" --authenticationDatabase admin --sslAllowInvalidCertificates --oplog
  1. Modify BSON files replacing the new controller UUID with the old one:
$ cd dump/
$ sudo cp -r juju juju.orig
$ for f in $(grep -arl 49153454-6367-447e-8b45-9c1d72fad421 *); do sudo sed -i s/"49153454-6367-447e-8b45-9c1d72fad421"/"c6d7b3b0-4cd8-4678-80d7-a05def24ffb1"/g $f; done
  1. Drop juju database:
$ mongo 127.0.0.1:37017/juju -u "${user}" -p "${password}" --sslAllowInvalidCertificates --ssl --authenticationDatabase admin
> db.dropDatabase()
  1. Restore juju DB from modified dump:
$ sudo /snap/juju-db/current/bin/mongorestore --db juju -h 127.0.0.1 --port 37017 --ssl -u "${user}" -p "${password}" --authenticationDatabase admin --sslAllowInvalidCertificates dump/juju
  1. Update the juju Agent:

Change 49153454-6367-447e-8b45-9c1d72fad421 to c6d7b3b0-4cd8-4678-80d7-a05def24ffb1 in the following files:

  • /var/lib/juju/agents/machine-0/agent.conf
  • /var/lib/juju/bootstrap-params
  1. Reboot the controller machine:
$ sudo reboot
  1. Enable HA Mode
    If use HA mode with the original controller, enable HA matching the original number of controllers.

  2. SSH back and Validate the UUID changes:

$ juju ssh 0

$ export user=$(sudo grep tag /var/lib/juju/agents/machine-*/agent.conf | cut -d' ' -f2)
$ export password=$(sudo grep statepassword /var/lib/juju/agents/machine-*/agent.conf | cut -d' ' -f2)
$ mongo 127.0.0.1:37017/juju -u "${user}" -p "${password}" --sslAllowInvalidCertificates --ssl --authenticationDatabase admin

> db.models.find({});
> db.controllers.find({});
> exit
  1. Finally Re-Try Restore juju backup

Please not that all other environment settings such as IP addresses and such must match your original deployment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions