This script recursively copies all secrets from one path to another in a HashiCorp Vault (KV version 1) instance.
vaultCLI installed and configured.jqinstalled.
# For Ubuntu/Debian
sudo apt install jq
# For CentOS/RHEL
sudo yum install jq
# For MacOS
brew install jqModify the following variables inside copy_secrets.sh to match your paths:
VAULT_SOURCE="dev/firstSecret"
VAULT_TARGET="dev/secondSecret"chmod +x copy_secrets.sh./copy_secrets.sh- Ensure your Vault token or environment has sufficient permissions:
- Read permissions on the source path.
- Write permissions on the target path.
- This script is designed specifically for Vault KV v1. If you're using KV v2, adjustments to paths and API calls will be required.
The script will output errors encountered during secret retrieval or writing but will continue processing remaining secrets.
Test the script in a non-production environment or on a small subset of secrets to ensure expected behavior.