operator migrate
The operator migrate
command copies data between storage backends to facilitate
migrating Vault between configurations. It operates directly at the storage
level, with no decryption involved. Keys in the destination storage backend will
be overwritten, and the destination should not be initialized prior to the
migrate operation. The source data is not modified, with the exception of a small lock
key added during migration.
This is intended to be an offline operation to ensure data consistency, and Vault will not allow starting the server if a migration is in progress.
Examples
Migrate all keys:
Migration is done in a consistent, sorted order. If the migration is halted or exits before completion (e.g. due to a connection error with a storage backend), it may be resumed from an arbitrary key prefix:
Configuration
The operator migrate
command uses a dedicated configuration file to specify the source
and destination storage backends. The format of the storage stanzas is identical
to that used to configure Vault,
with the only difference being that two stanzas are required: storage_source
and storage_destination
.
Migrating to integrated raft storage
Example Configuration
The below configuration will migrate away from Consul storage to integrated
raft storage. The raft data will be stored on the local filesystem in the
defined path
. node_id
can optionally be set to identify this node.
cluster_addr must be set to the
cluster hostname of this node. For more configuration options see the raft
storage configuration documentation.
If the original configuration uses "raft" for ha_storage
a different
path
needs to be declared for the path in storage_destination
and the new
configuration for the node post-migration.
Run the migration
Vault will need to be offline during the migration process. First, stop Vault. Then, run the migration on the server you wish to become a the new Vault node.
After migration has completed, the data is stored on the local file system. To use the new storage backend with Vault, update Vault's configuration file as described in the raft storage configuration documentation. Then start and unseal the vault server.
Join additional nodes
After migration the raft cluster will only have a single node. Additional peers should be joined to this node.
If the cluster was previously HA-enabled using "raft" as the ha_storage
, the
nodes will have to re-join to the migrated node before unsealing.
Usage
The following flags are available for the operator migrate
command.
-config
(string: <required>)
- Path to the migration configuration file.-start
(string: "")
- Migration starting key prefix. Only keys at or after this value will be copied.-reset
- Reset the migration lock. A lock file is added during migration to prevent starting the Vault server or another migration. The-reset
option can be used to remove a stale lock file if present.