Backup configuration
Set the following environment variables to enable backup. The managed identity assigned to the App Service must have Blob Data Contributor (or equivalent write) access to the target container.Backup uses
DefaultAzureCredential. On App Service this resolves to the system-assigned or user-assigned managed identity. For a user-assigned identity, also set FLUX_MANAGED_IDENTITY_CLIENT_ID.When backups run
After each successful sync the worker:- Issues a
CHECKPOINTto flush the DuckDB WAL to the main file. - Copies the checkpointed
.duckdbfile to a temporary directory. - Uploads the copy to the configured Blob container under the prefix
duckdb/with the naming patternflux-<YYYYMMDDTHHmmssZ>.duckdb. - Prunes any blobs under
duckdb/flux-whoselast_modifiedtimestamp is older thanFLUX_BACKUP_RETENTION_DAYS.
overwrite=False. Each sync produces a distinct timestamped blob rather than overwriting a single slot.
Analytics snapshot architecture
For multi-instance deployments, Flux supports an analytics snapshot tier that separates the singleton writer from read-only web-process consumers:
In snapshot mode the web process is a read-only consumer; the singleton writer publishes immutable snapshots after each successful job. This eliminates the cross-process DuckDB write lock contention for multi-instance App Service plans.
The analytics snapshot daily retention tier (
FLUX_ANALYTICS_SNAPSHOT_DAILY_RETENTION_DAYS) is separate from the legacy per-sync backup controlled by FLUX_BACKUP_*. When snapshot publishing is enabled, the per-UTC-day snapshot tier serves as the analytical backup.Startup recovery
SetFLUX_RECOVER_DATABASE_FROM_LATEST_BACKUP=true to trigger automatic recovery at startup. When this flag is set, Flux:
1
Validate current database
Flux opens the existing database read-only and checks that the minimum required tables (
azure_integration, resource_snapshots) are present and that resources_current contains at least one row. If the database is valid, no recovery is performed.2
Identify candidates
If validation fails, Flux lists up to 8 backup blobs from the container (prefix
duckdb/flux-, non-zero size), sorted by last_modified descending.3
Download and validate
Flux downloads each candidate to a temporary file and runs the same validation check. Candidates that fail validation are discarded and the next one is tried.
4
Atomic replacement
Once a valid backup is found, Flux:
- Acquires the cross-process writer lock (up to 180-second timeout).
- Renames the damaged database to
flux.duckdb.corrupt-<timestamp>(preserving it for post-mortem). - Renames any
.walfile alongside it. - Atomically renames the validated backup into place.
5
Log outcome
Flux logs the restored backup name, the path of the preserved damaged file, and the resource count from the restored database.
Manual restore
If you need to restore a specific backup outside of the automatic startup flow:- Download the desired backup blob from the
duckdb/prefix in your backup container. - Stop the Flux App Service (or all processes that hold the DuckDB writer lock).
- Replace the file at
FLUX_DUCKDB_PATH(defaultdata/flux.duckdb) with the downloaded backup. - Remove any stale
.walfile alongside it. - Restart Flux.
Identity requirements
Recovery uses
ManagedIdentityCredential directly (not DefaultAzureCredential). Ensure the managed identity has at minimum read access to the backup container for the recovery path, and write access for the backup upload path.