Env files
moira edits the *.env files a stack’s services load with env_file. Every save is
conditional on the version you read, backed up first, and followed by an offer to apply the
change.
Which files are editable
Section titled “Which files are editable”A file is editable when it:
- sits directly in the stack directory and is named
<something>.env; - is referenced as an
env_fileby the stack’s current Compose model; - is a regular file: not a symlink and not hard-linked;
- is valid UTF-8 and at most 1 MiB.
Edit anything else over SSH.
moira env shop-prod # the file shop-prod uses (or pick from a list)moira env edge/shop/ staging.env # a specific file in a stack-
moira downloads the file and opens a private copy (mode
0600) in$VISUAL,$EDITORorvi. The copy is deleted when the editor exits, even on failure or Ctrl-C. -
It prints a masked diff on stderr. Values never appear:
~ DATABASE_URL=***+ FEATURE_FLAGS=***- LEGACY_TOKEN=*** -
You confirm with
y(or pass--yes). -
The save sends the version you read in
If-Match. On success, moira prints the backup path:Backup .history/prod.env.20261122T140000Z -
For each service that uses the file it asks
apply now? [Y/n].--yesaccepts every apply;--no-applyskips them. Apply output is hidden because it could contain env values; only the job status is shown.
An unchanged file prints no changes.
Concurrent edits
Section titled “Concurrent edits”If the file changed on the host while you were editing, the server rejects the save. moira then compares both versions with the one you started from:
- Disjoint changes (different keys) are merged. moira shows the masked diff against the current file and asks again.
- Overlapping changes (the same key, duplicate assignments, or conflicting reorders) need
manual reconciliation. On a terminal, moira opens a copy of the current server file, shows
the path of a private copy of your edit, and asks before saving. Without a terminal, it exits
1.
History and restore
Section titled “History and restore”Every save first copies the previous version to <stack>/.history/<file>.<UTC timestamp>
(mode 0600). The newest 20 automatic backups per file are kept. Hand-made
<file>.bak-<suffix> copies next to the file also appear in history and are never pruned.
moira env shop-prod historymoira env shop-prod restore 20261122T140000Zmoira env shop-prod restore bak-cutover --yes --no-applyA restore is an ordinary save of the old content: same masked review, same conflict check, and it gets its own backup.
In the web UI
Section titled “In the web UI”The env editor in moira ui shows keys with masked values. Reveal a single
value with an explicit click, stage edits per key, review the masked diff, then Save or
Save & Apply. Files with ambiguous dotenv syntax open in a raw editor.