Vault Migrate
A Python tool for migrating secrets between HashiCorp Vault instances, supporting KV (Key-Value) secrets engines with namespace and mount point mapping.
Features
- Migrate secrets between different Vault instances
- Support for Vault namespaces
- Flexible mount point and path prefix mapping
- Configurable TLS verification and custom CA bundles
- JSON-based configuration for reproducible migrations
Installation
Using pipx (Recommended)
pipx installs the tool in an isolated environment while making it globally available:
pipx install vault_migrate
Using uv
uv is a fast Python package installer:
# Install globally
uv tool install vault_migrate
Manual Installation
For development or manual installation:
# Clone the repository
git clone https://github.com/TheLonelyGhost/vault-migrate.git
cd vault-migrate
# Create a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install the package
pip install -e .
Usage
The vault-migrate command takes a single positional argument: the path to your migration configuration file (typically named migrate.json).
vault-migrate migrate.json
Or with a custom path:
vault-migrate /path/to/my-migration-config.json
Configuration
Create a migrate.json file with your migration configuration. Here's a complete example:
{
"settings": {
"source": {
"address": "https://vault-source.example.com:8200",
"token": "hvs.source-token-here",
"tls_verify": true,
"ca_bundle_path": "/path/to/source-ca-bundle.pem"
},
"target": {
"address": "https://vault-target.example.com:8200",
"token": "hvs.target-token-here",
"tls_verify": true,
"ca_bundle_path": "/path/to/target-ca-bundle.pem"
},
"mapping_file": "out/mapping.json",
"timeout": 10
},
"kv": [
{
"from": {
"namespace": "source-namespace",
"mount": "secret",
"path_prefix": "app/production"
},
"to": {
"namespace": "target-namespace",
"mount": "kv",
"path_prefix": "applications/prod"
}
},
{
"from": {
"namespace": "source-namespace",
"mount": "secret",
"path_prefix": "shared/credentials"
},
"to": {
"namespace": "target-namespace",
"mount": "kv",
"path_prefix": "shared/creds"
}
}
]
}
Configuration Schema
settings (required)
Global settings for the migration:
-
source(required): Source Vault connection configurationaddress(string, required): Vault server URLtoken(string, required): Vault authorization tokentls_verify(boolean, optional): Enable TLS verification (default:true)ca_bundle_path(string, optional): Path to custom CA certificate bundle
-
target(required): Target Vault connection configuration- Same fields as
source
- Same fields as
-
mapping_file(string, optional): Path to output mapping file (default:"out/mapping.json") -
timeout(integer, optional): Request timeout in seconds (default:10)
kv (optional)
Array of KV secrets engine mappings. Each mapping defines how secrets should be migrated from source to target:
-
from(required): Source locationnamespace(string, required): Source Vault namespacemount(string, required): Source KV mount pointpath_prefix(string, required): Source path prefix within the mount
-
to(required): Target locationnamespace(string, required): Target Vault namespacemount(string, required): Target KV mount pointpath_prefix(string, required): Target path prefix within the mount
Minimal Configuration Example
For a simple migration without namespaces or custom paths:
{
"settings": {
"source": {
"address": "https://vault-old.example.com:8200",
"token": "hvs.source-token"
},
"target": {
"address": "https://vault-new.example.com:8200",
"token": "hvs.target-token"
}
},
"kv": [
{
"from": {
"namespace": "",
"mount": "secret",
"path_prefix": ""
},
"to": {
"namespace": "",
"mount": "secret",
"path_prefix": ""
}
}
]
}
Requirements
- Python 3.10 or higher
- Network access to both source and target Vault instances
- Valid Vault tokens with appropriate permissions for reading and writing secrets
License
See LICENSE file for details.
Metadata
Release files for vault_migrate 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| vault_migrate-0.1.9.tar.gz | 12.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vault_migrate-0.1.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.9 kB
Release files / vault_migrate-0.1.9.tar.gz
| Download URL | vault_migrate-0.1.9.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
187ed4916b4ef7284f6617e31d6d2aa79f328c26d416e0c53fbba4d44b716980
|
|
BLAKE2b-256 checksum How to use checksums |
4b3796f3405b38405af5da097b441768c346e84752e3f343f3ab7e56a5bd70bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / vault_migrate-0.1.9-py3-none-any.whl
| Download URL | vault_migrate-0.1.9-py3-none-any.whl |
|---|---|
| Size | 12.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e8a7ad63826775adcc7b1d414da386f2446a306bf8c335ad1bc8240d88cdfd46
|
|
BLAKE2b-256 checksum How to use checksums |
6d61f3d7eab558ffe840750e8abf7482ffa8b40e97b067d82328a76776f9d7ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|