Auditing which way my environment sync actually ran
The name sync_env.py was doing too much explanatory work in my inventory.
I’d described it as taking credentials from a database and writing them into project .env files. The October audit found that the arrows went the other way: the job read the files and ingested their key-value records into PostgreSQL.
That changed what the service meant for migration and recovery. Moving the credentials database wouldn’t automatically rebuild every project’s environment file.
I followed the reads and writes
The existing nightly job read its own connection configuration, queried a registry of environment-file paths, parsed those files and inserted or updated their keys in database tables.
A separate file-to-database example by Dreftymac, released into the public domain. My job reads environment files rather than CSV.
The October 20 inventory correction was an audit of that existing job, rather than the week I first installed it. Its data flow was:
2 a.m. cron -> sync_env.py
├─ reads connection configuration
├─ reads env_file_paths registry
└─ reads registered project .env files
-> key/value tables in env_sync
-> creds_postgres_data volume
The registry contained ten paths across product, home and development work. A registered blog path was absent at the audit. Ten registrations didn’t mean ten files were successfully imported.
A dummy setting makes the direction obvious
Suppose a registered project’s file contains this teaching example:
DEMO_SERVICE_MODE=development
The import reads that setting into the table associated with the file. Changing the file gives the next import a different value to write. Changing only the stored database value doesn’t cause this job to update the file.
The job reads the registry to find each file. Once it has the file’s contents, it inserts or updates the corresponding rows in the destination table.
Applications configured from those local files still consume the files. A central stored copy can support retrieval or recovery, but that is a different path that needs its own implementation.
The recovery questions became more specific
For a replacement host, I needed to account for the source files, the registry, the importer, its connection configuration and the database’s persistent volume. Restoring only one of those pieces wouldn’t necessarily restore the others.
The schedule also creates a window between a local edit and the next import. A database snapshot is a copy of what the job captured, not proof that it includes the latest file change. Upserting discovered keys doesn’t, by itself, define how deleted keys or missing files should be handled in a complete restore.
The corrected arrow belongs in the ownership audit. If I restore the database, I still have to restore the project files separately.