d.rymcg.tech icon indicating copy to clipboard operation
d.rymcg.tech copied to clipboard

Centralized backup of .env files (`envkeeper`)

Open EnigmaCurry opened this issue 7 months ago • 0 comments

Create an etckeeper like helper program that d.rymcg.tech can use to manage the backup of .env files.

BACKUP_DIR=~/git/$(hostname)-env-backup
[email protected]:whomever/whatever.git
ROOT_DIR=~/git/vendor/enigmacurry/d.rymcg.tech

# Set ENVKEEPER_HOME so it knows where the backup is.
$ export ENVKEEPER_HOME=${BACKUP_DIR}

# Initialize the backup
$ envkeeper init ${BACKUP_DIR}

# Use embedded git to add a remote (or run any git command):
$ envkeeper git remote add origin ${BACKUP_REMOTE}

# Only have to add files once to track them forever:
$ envkeeper add ${ROOT_DIR}/whoami/.env_test-default

# Add arbitrary metadata to the next commit (ie JSON or whatever) :
$ envkeeper meta '{"d.rymcg.tech": { "git": { "head": "XXXX" } }}'

# Commit will git add, and commit all changes to all previously added .env files.
$ envkeeper commit "Making a commit to env keeper repo"

# Push changes
$ envkeeper push

Create new variables in the root d.ry .env file:

  • ENVKEEPER_ENABLED true or false to enable envkeeper for this context.
  • ENVKEEPER_HOME path to the backup directory.

Create a hook for make install so that it calls envkeeper add, envkeeper commit, and envkeeper push automatically, but only if ENVKEEPER_ENABLED is true.

EnigmaCurry avatar Jul 02 '24 19:07 EnigmaCurry