aleixolucas/hashicorpvault-backup

By aleixolucas

Updated 4 months ago

Backup for hashicorp vault Kv

Image
Content Management System
Security
Web Servers

36

HASHICORP VAULT BACKUP

This script back up the key value (Kv) in hashicorp vault to a txt file

Software Validation

Vault versionDocker versionPython versionOperational systemTest result
1.15.625.0.33.11.8Arch linux:white_check_mark:
1.15.624.0.53.8.10Ubuntu 22.04:white_check_mark:

Environment variables

NameExampleDescription
VAULT_ADDRhttps://vault.yourinstance.labVault address
VAULT_TOKENhvs.qwertyqwertyqwertyqwertyYour vault token
VAULT_BACKUP_FILEvault-file-backup.txtOutput file name (optional)

Run backup with docker

This will create the output file on your actual directory

docker run \
    -v $PWD:/opt/vaultbackup \
    -e VAULT_ADDR="https://vault.yourinstance.lab" \
    -e VAULT_TOKEN="hvs.qwertyqwertyqwerty" \
    aleixolucas/hashicorpvault-backup:v1

Run script with python3

pip3 install -r requirements.txt
export VAULT_ADDR=https://vault.yourinstance.lab
export VAULT_TOKEN=hvs.qwertyqwertyqwerty
python3 main.py

FAQ

  • You can make the script place the back up file to a specific folder, but make sure this folder already exists.
  • Some environment variables are required.
  • The environment where you are running the backup must to have access on your vault address.
  • Your the script will only back up the key values that your token have access.
  • If you are runnig with docker, you shall have docker installed.
  • If you are running with python, make sure you have python3 installed.
  • You can modify the source and rebuild the docker image as you need.

Docker Pull Command

docker pull aleixolucas/hashicorpvault-backup