EnigmaCurry / d.rymcg.tech

A collection of self-hosted docker-compose projects with Traefik reverse proxy, integrated auth, and administrative Makefiles for easy maintainance
MIT License
46 stars 9 forks source link

Centralized backup of .env files (`envkeeper`) #252

Open EnigmaCurry opened 5 days ago

EnigmaCurry commented 5 days ago

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
BACKUP_REMOTE=git@example.com: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:

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.