#!/bin/sh

set -eo pipefail

{% if vault_backup_token is defined %}
if [ -e /etc/profile.d/vault.sh ]; then
  source /etc/profile.d/vault.sh
fi
export VAULT_TOKEN={{ vault_backup_token }}
vault operator raft snapshot save {{ vault_root_dir }}/backup/vault.snap
{% endif %}
