Categorygithub.com/alv91/vault-backup
modulepackage
0.0.0-20220421160706-252c7c275cdc
Repository: https://github.com/alv91/vault-backup.git
Documentation: pkg.go.dev

# README

Vault-backup

vault-backup is a simple command line tool for doing hashicorp vault backups using raft snapshots on S3. It allows also to restore them. It's good to have version control in bucket enabled because apart from a specific backup, it always copies the last one under the "latest" name.

Install

You can install vault-backup using the following go command

go install github.com/alv91/vault-backup

or the easiest way use docker image

docker pull alv91/vault-backup:latest

If you want to use another version, check docker hub

How to use

This tool has two main commands, backup and restore. You can use flags, environment variables or config yaml to set the same values.

VariableFlagDescriptionRequiredDefault
CONFIG--configconfig filefalse$HOME/.vault-backup.yaml
VAULT_ADDRESS--vault-address / -aaddress of hashicorp vault servertruehttps://127.0.0.1:8200
VAULT_TOKEN--vault-token / -tvault authentication tokentrue
VAULT_NAMESPACE--vault-namespace / -nvault namespace to usefalseadmin
VAULT_TIMEOUT--vault-timeoutvault client timeoutfalse60s
S3_ACCESS_KEY--s3-access-keyAWS access key with permissions to bucketfalse
S3_SECRET_KEY--s3-secret-keyAWS secret key with permissions to bucketfalse
S3_BUCKET--s3-bucketS3 bucket nametrue
S3_REGION--s3-regionS3 bucket regionfalseeu-central-1
S3_ENPOINT--s3-endpointS3 endpoint (if you want to use S3 compatible storage like minio)false
S3_FILENAME--s3-filenameFile name of the backup that you want to restore from S3falsebackup-latest.snap
FORCE--force / -fPass force flag to vault restorefalsefalse

If you are using EKS you don't need to set access and secret key, you can use service account with associated role to access S3 instead.

For more details use vault-backup --help

Example usage

backup

./vault-backup backup -t token -a http://vault.local:8200 --s3-access-key xxx --s3-secret-key xxx --s3-bucket test-vault-backup
VAULT_TOKEN=xxx VAULT_ADDRESS=http://vault.vault:8200 S3_ACCESS_KEY=xxx S3_SECRET_KEY=xxx S3_BUCKET=vault-backup-bucket ./vault-backup backup
docker run -it --rm -e VAULT_TOKEN=xxx -e VAULT_ADDRESS=http://vault.vault:8200 -e S3_ACCESS_KEY=xxx -e S3_SECRET_KEY=xxx -e S3_BUCKET=vault-backup-bucket alv91/vault-backup backup

restore

./vault-backup restore -t token -a http://vault.local:8200 --s3-access-key xxx --s3-secret-key xxx --s3-bucket test-vault-backup --s3-filename backup-20060102-150405.snap
VAULT_TOKEN=xxx VAULT_ADDRESS=http://vault.vault:8200 S3_ACCESS_KEY=xxx S3_SECRET_KEY=xxx S3_BUCKET=vault-backup-bucket S3_FILENAME=backup-20060102-150405.snap ./vault-backup restore
docker run -it --rm -e VAULT_TOKEN=xxx -e VAULT_ADDRESS=http://vault.vault:8200 -e S3_ACCESS_KEY=xxx -e S3_SECRET_KEY=xxx -e S3_BUCKET=vault-backup-bucket alv91/vault-backup restore 

Helm

To install the helm chart use the following command. It will create the cron job with execution every 10 minutes.

helm repo add thebug https://thebug.pl/helm-charts
helm install --name vault-backup --namespace vault-backup thebug/vault-backup \
  --set vault.address=http://vault.vault:8200 \ 
  --set vault.token=xxx --set s3.accessKey=xxx \
  --set s3.secretKey=xxx \
  --set s3.bucket=vault-backup-bucket \
  --set schedule="*/10 * * * *"

# Packages

No description provided by the author