Maintenance Commands¶
Commands for data migration, statistics synchronization, and other operational maintenance tasks.
move-references¶
Migrate vulnerability references from the deprecated reference + reference_vulnerability_association model to the newer VulnerabilityReference model. This is a data migration utility needed during specific version upgrades.
Note: This command was previously undocumented. It should be run when upgrading from versions that used the old reference model.
faraday-manage move-references [OPTIONS]
Options¶
| Option | Type | Default | Description |
|---|---|---|---|
-a, --all-workspaces |
Boolean | false |
Migrate references in all workspaces |
-w, --workspace-name |
String | — | Migrate references in a specific workspace |
One of --all-workspaces or --workspace-name must be provided.
Behavior¶
- Queries the old
reference/reference_vulnerability_associationtables for the specified workspace(s) - Inserts the data into the new
VulnerabilityReferencetable usingINSERT ... ON CONFLICT DO NOTHING - Verifies the migration by comparing row counts between old and new tables
- If counts match: deletes the old association records
- If counts differ: prints a warning and does not delete old records
Examples¶
# Migrate a single workspace
faraday-manage move-references -w my-project
# Migrate all workspaces (may take a while for large databases)
faraday-manage move-references -a true
Output¶
Working on workspace my-project ...
Moved 1523 reference/s from my-project
Deleting old references associations ...
All associations were deleted successfully
Or if no references are found:
Working on workspace my-project ...
No references found...
Common Errors¶
| Error | Cause | Solution |
|---|---|---|
Options required |
Neither workspace option provided | Use -a true or -w <workspace-name> |
There are differences between old references and moved references... |
Count mismatch after migration | Investigate manually; old data is preserved |
sync-hosts-stats¶
Recalculate and synchronize vulnerability severity statistics for all hosts across workspaces. This is useful when dashboard statistics become out of sync with actual vulnerability data.
Note: This command was previously undocumented. Use it when dashboard vulnerability counts or severity distributions appear incorrect.
faraday-manage sync-hosts-stats [OPTIONS]
Options¶
| Option | Type | Default | Description |
|---|---|---|---|
-a, --async-mode |
Boolean | false |
Run the update asynchronously via Celery task queue |
Behavior¶
- Queries all host IDs and workspace IDs from the database
- Dispatches the
update_host_statstask with the collected IDs - In synchronous mode (default): runs the update inline, blocking until complete
- In async mode: dispatches a Celery task to process in the background (requires Celery to be enabled in settings)
Community Edition Note¶
Async mode requires Celery to be enabled (faraday_server.celery_enabled). If Celery is not enabled and async mode is requested, the command will print an error:
Error: To use async mode you must have celery enabled in your settings
For community installations, use the default synchronous mode.
Examples¶
# Synchronous update (recommended for community edition)
faraday-manage sync-hosts-stats
# Asynchronous update via Celery (requires Celery enabled)
faraday-manage sync-hosts-stats -a true
Output¶
[*] Syncing hosts stats ...
[*] Found 2847 hosts ...
[!] This may take a while ...
[*] Updating synchronously
When to Use¶
- Dashboard vulnerability counts don't match actual data
- After bulk vulnerability import/deletion
- After database restoration from backup
- After upgrading Faraday versions
- When severity distribution charts appear incorrect
add-scanner¶
Add a Security Scanner (cloud agent) to this instance without going through the API. It does what POST /_api/v3/cloud_agents/add_scanner does, without HTTP or user authentication. It uses the instance license key and the cloud_agents settings (cam and public_key).
faraday-manage add-scanner --slug <slug>
Options¶
| Option | Type | Default | Description |
|---|---|---|---|
-s, --slug |
String | — | Scanner slug, for example first-scan. Required |
Behavior¶
- If the scanner already exists locally, the command does nothing and exits with
0(idempotent). - Otherwise, it asks Cloud Agent Manager (CAM) to add the scanner, saves it locally and exits with
0. - If the local save fails after CAM created the association, the association is deleted in CAM. After a
200from CAM nothing is deleted.
Exit Codes¶
| Code | Meaning |
|---|---|
0 |
Scanner added, or already present locally |
1 |
Error (missing settings or license, CAM error or unreachable, local save failure) |
3 |
CAM already has the scanner for this instance but no local access token can be recovered. Ask a CAM operator to recover the access token. Do not delete and recreate the scanner, because that resets its usage counters |
Examples¶
faraday-manage add-scanner --slug first-scan
optimize-indices¶
Create performance indices that are too slow to build during faraday-manage migrate on large databases. Run it after upgrading an existing installation.
faraday-manage optimize-indices [--yes]
Asks for confirmation first, since the build may take a long time; --yes skips it. Indices are built concurrently, so Faraday keeps working meanwhile. Safe to run more than once.