Operations CLI
AsterDrive now includes a set of command-line tools for these scenarios:
- The service is already deployed, but you want to check the database and key settings offline first.
- The admin panel is temporarily inaccessible, and you need to view or modify system settings directly.
- You need to run
node enrollon a follower node shell. - You are preparing to migrate SQLite to PostgreSQL or MySQL, or migrate back the other way.
- You want check results to be handled by scripts, CI, or an operations platform.
These commands are still part of the same aster_drive executable.
Running ./aster_drive directly starts the service. Running it with a subcommand performs an operations task.
Service roles
Section titled “Service roles”./aster_drive [serve [all|api|worker]] defaults to all. Follower remains config-selected. See separate roles for ownership, cancellation, limits and migration.
Server startup (serve all/api/worker or no subcommand), --config-file / --data-dir, and version / version --json remain available without the operations-cli Cargo feature. That feature controls the operational subcommands below. Build a service-only binary with cargo build --no-default-features --features server, or pass --build-arg CARGO_FEATURES=server to Docker.
Output channels in scripts
Section titled “Output channels in scripts”Command results go to stdout; errors, interactive prompts, and migration progress go to stderr. Specify --output-format json for machine-readable operational reports. Redirecting stdout does not disable prompts on terminal stderr, and automated writes still require --yes. Server-only and full builds retain the same command names, arguments, and output contracts; compiled features determine which subcommands are available.
Command Quick Reference
Section titled “Command Quick Reference”| What you want to do | Command | When to use it |
|---|---|---|
| Check database, migrations, public site URL, mail, and default policies | doctor | New deployment, before launch, after upgrade |
| Deep-check capacity, blob references, object inventory, and folder tree | doctor --deep | When you suspect data and storage are inconsistent |
| Automatically fix some counter drift | doctor --deep --fix | After confirming the CLI is allowed to modify counters |
| View system settings offline | config list / config get | When the admin panel is inaccessible, or for scripts |
| Modify system settings offline | config set / config import | Maintenance windows, batch configuration, disaster recovery |
| Complete enrollment on a follower | node enroll | After the primary admin panel generates an enrollment command |
| Migrate between SQLite / PostgreSQL / MySQL | database-migrate | Switching database backends or rehearsing migration |
When running outside the instance directory, use --config-file /srv/asterdrive/data/config.toml or --data-dir /srv/asterdrive/data. Database target precedence is explicit --database-url, ASTER_CLI_DATABASE_URL, then [database].url in that config file. doctor and config only access an existing instance; they do not create a default config file or SQLite database when the target is missing. database-migrate always requires explicit source and target URLs.
Prometheus and OTLP exporters absent from the binary, including their exporter-specific settings, are skipped without blocking offline config operations or server startup. doctor checks the effective instance configuration. Compiled and enabled exporters still require valid settings and credentials.
Write Previews and Confirmation
Section titled “Write Previews and Confirmation”config validate checks whether a candidate value or backup satisfies configuration rules; it does not write. --dry-run shows the changes a write command would make against current database state and does not write to the database or publish a config reload notification:
./aster_drive config --database-url "$DB_URL" set branding_title 'New title' --dry-run./aster_drive config --database-url "$DB_URL" delete custom.example --dry-run./aster_drive config --database-url "$DB_URL" import --input-file /secure/config.json --dry-run./aster_drive doctor --database-url "$DB_URL" --deep --fix --dry-run./aster_drive database-migrate --source-database-url "$SOURCE_URL" --target-database-url "$TARGET_URL" --dry-runInteractive terminals ask for confirmation before config set, config delete, config import, doctor --fix, node enroll, and an actual database-migrate; the default answer is no. Without a terminal, pass --yes (or set ASTER_CLI_YES=true), otherwise the command fails before writing. --yes only skips confirmation; it does not skip backup requirements, input validation, or command-specific safety checks. Review the dry-run output before applying a change.
The distinction is simple: validate checks the input itself; --dry-run resolves it against current state and shows what would be added, updated, or deleted.
Interactive config writes display the validated plan before confirmation, keeping sensitive values redacted. node enroll has no dry-run because consuming a remote enrollment token cannot be rehearsed offline. doctor --fix --dry-run performs the audit and lists counter differences. Migration previews and verification require an existing SQLite target file (use touch to prepare an empty target); only actual migrations can create the target database file.
Human-readable config values escape terminal control characters so backup contents cannot alter the display or confirmation prompt. Plain-text values double literal backslashes to distinguish them from control escapes, such as \t for a tab. Displayed JSON arrays and quoted current values use valid JSON Unicode escapes, such as \u009b, and remain parseable. JSON reports and backups preserve the original values. Preview status reads planned, not written; keeping a saved value reports unchanged.
Shell Completion
Section titled “Shell Completion”Completion scripts are generated from the CLI’s Clap command definitions. Installation does not connect to the service or database and does not access the network. Install for the shell named by $SHELL:
./aster_drive completions installOr select Bash, Zsh, or Fish explicitly:
./aster_drive completions install bash./aster_drive completions install zsh./aster_drive completions install fishScripts go to user-level standard directories: Bash uses $XDG_DATA_HOME/bash-completion/completions/aster_drive (defaulting to ~/.local/share/...), Zsh uses $XDG_DATA_HOME/zsh/site-functions/_aster_drive, and Fish uses $XDG_CONFIG_HOME/fish/completions/aster_drive.fish. Bash requires bash-completion to be installed and initialized. For Zsh, add the site-functions directory to fpath before compinit, for example fpath=("${XDG_DATA_HOME:-$HOME/.local/share}/zsh/site-functions" $fpath). Fish loads its completions directory automatically. Restart the shell or reload its completion configuration to use the script. Generated contents include root and subcommands, options, and enum values declared to Clap.
After installing completion, check script syntax with bash -n <installed-path>, zsh -n <installed-path>, or fish -n <installed-path>. In a new terminal, press Tab after aster_drive to verify subcommands and after aster_drive serve to verify enum values.
Prepare the Database URL First
Section titled “Prepare the Database URL First”The most common forms are:
sqlite:///var/lib/asterdrive/data/asterdrive.db?mode=rwcpostgres://user:password@127.0.0.1:5432/asterdrivemysql://user:password@127.0.0.1:3306/asterdriveIf you use the official Docker container, the simplest approach is usually to enter the container first, then run these commands:
docker exec -it asterdrive shThat avoids confusion between SQLite paths, mounted volumes, and actual file locations inside the container.
Use Environment Variables Instead of Common Arguments
Section titled “Use Environment Variables Instead of Common Arguments”Operations scripts can use ASTER_CLI_* to supply defaults for the corresponding arguments. Database targets and output formats affect their operations commands; the instance-location options also apply to serve and startup without a subcommand.
| Environment variable | Corresponding argument | Applicable commands |
|---|---|---|
ASTER_CLI_DATABASE_URL | --database-url | doctor, config, node enroll |
ASTER_CLI_CONFIG_FILE | --config-file | server startup and CLI commands |
ASTER_CLI_DATA_DIR | --data-dir | server startup and CLI commands |
ASTER_CLI_OUTPUT_FORMAT | --output-format | doctor, config, node, database-migrate |
ASTER_CLI_MASTER_URL | node enroll --master-url | node enroll |
ASTER_CLI_ENROLLMENT_TOKEN | node enroll --token | node enroll |
ASTER_CLI_SOURCE_DATABASE_URL | database-migrate --source-database-url | database-migrate |
ASTER_CLI_TARGET_DATABASE_URL | database-migrate --target-database-url | database-migrate |
doctor also has these script-friendly switches:
ASTER_CLI_DOCTOR_STRICT=trueASTER_CLI_DOCTOR_DEEP=trueASTER_CLI_DOCTOR_FIX=trueASTER_CLI_DOCTOR_SCOPE=blob-ref-counts,storage-objectsASTER_CLI_DOCTOR_POLICY_ID=3During database migration, if you need progress output or a smaller batch size, you can also use:
ASTER_CLI_PROGRESS=1ASTER_CLI_COPY_BATCH_SIZE=100Deployment Check: doctor
Section titled “Deployment Check: doctor”After first deployment, or before production launch, run this first:
./aster_drive doctor \ --database-url "sqlite:///var/lib/asterdrive/data/asterdrive.db?mode=rwc"Default mode checks the places most likely to go wrong:
- whether the database can be connected
- whether pending migrations remain
- if the backend is SQLite, whether the
FTS5 + trigram tokenizersearch acceleration capability is available, and whether related FTS tables / triggers are complete - whether runtime system settings can be read normally
- whether
Public Site URLis empty or malformed - whether
Public Site URLis stillhttp://, which means production lacks HTTPS - whether mail delivery configuration is complete
- whether preview application configuration parses correctly
- whether the default storage policy and default policy group are ready
If you want warn to count as failure, add:
./aster_drive doctor \ --database-url "sqlite:///var/lib/asterdrive/data/asterdrive.db?mode=rwc" \ --strictFor script processing, add an output format:
./aster_drive doctor \ --output-format json \ --database-url "sqlite:///var/lib/asterdrive/data/asterdrive.db?mode=rwc"Best uses:
- first acceptance check after a new deployment
- health check after upgrade
- after changing
Public Site URL, mail, or preview applications, confirm the config was not broken - confirm a default SQLite deployment really has search acceleration instead of silently falling back to full table scans
If you suspect existing “data and storage inconsistency” in the database, run a deep check:
./aster_drive doctor \ --database-url "sqlite:///var/lib/asterdrive/data/asterdrive.db?mode=rwc" \ --deep--deep adds these checks:
storage-usage: comparesusers.storage_used/teams.storage_usedwith actual usage from files and historical versionsblob-ref-counts: comparesfile_blobs.ref_countwith real references fromfiles/ non-currentfile_revisionsstorage-objects: scans object paths under each storage policy to find missing blobs, untracked objects, and orphan thumbnailsfolder-tree: checks missing parent folders, cross-workspace parent folders, and folder cyclesrevision-ledger: checks history/head/predecessor pointers and thefilescurrent projection
If you only want part of the deep checks, narrow the scope:
./aster_drive doctor \ --database-url "sqlite:///var/lib/asterdrive/data/asterdrive.db?mode=rwc" \ --scope blob-ref-counts,storage-objectsIf you only want to check a specific storage policy, add:
./aster_drive doctor \ --database-url "sqlite:///var/lib/asterdrive/data/asterdrive.db?mode=rwc" \ --scope storage-objects \ --policy-id 3When counter drift is found, the CLI can fix it directly:
./aster_drive doctor \ --database-url "sqlite:///var/lib/asterdrive/data/asterdrive.db?mode=rwc" \ --deep \ --fixPay attention to four things:
--scopeonly affects deep checks. It does not disable base checks such as database connection, migrations, and runtime configuration.--policy-idonly applies toblob-ref-countsandstorage-objects;storage-usageandfolder-treestill check the whole database.--fixcurrently only repairsstorage_usedandfile_blobs.ref_countcounters. It does not automatically delete objects or modify folder structure.- Deep scans run in database batches and object storage pages, but they only validate path-level existence. They do not read object contents or calculate checksums.
Offline System Settings: config
Section titled “Offline System Settings: config”For normal settings changes, prefer Admin -> System Settings.
config is better for these cases:
- the admin panel is temporarily inaccessible
- you do not want to use a web page during a maintenance window
- you want to export, validate, or import system settings in bulk
List current items:
./aster_drive config \ --database-url "sqlite:///var/lib/asterdrive/data/asterdrive.db?mode=rwc" \ listView one item:
./aster_drive config \ --database-url "sqlite:///var/lib/asterdrive/data/asterdrive.db?mode=rwc" \ get \ --key public_site_urlValidate first, then write to the database:
./aster_drive config \ --database-url "sqlite:///var/lib/asterdrive/data/asterdrive.db?mode=rwc" \ validate \ --key public_site_url \ --value '["https://drive.example.com"]'
./aster_drive config \ --database-url "sqlite:///var/lib/asterdrive/data/asterdrive.db?mode=rwc" \ set \ --key public_site_url \ --value '["https://drive.example.com"]'public_site_url supports multiple public origins. When writing from the command line, pass a JSON string array:
./aster_drive config \ --database-url "sqlite:///var/lib/asterdrive/data/asterdrive.db?mode=rwc" \ set \ --key public_site_url \ --value '["https://drive.example.com","https://panel.example.com"]'Single-setting commands accept positional arguments; existing --key / --value scripts remain supported:
./aster_drive config get branding_title./aster_drive config set branding_title 'My Drive'./aster_drive config validate branding_title 'My Drive'./aster_drive config delete custom.exampleIn an interactive terminal, config set branding_title displays the setting’s type, description and current value before prompting. config set opens a searchable list of keys and descriptions; use arrows and Enter to select. Ordinary input is displayed; sensitive input shows asterisks while typing, with previous and result values remaining redacted, including custom settings marked sensitive in the database. No shortcut reveals sensitive input. --value-prompt explicitly requests the same interaction and does not hide ordinary input. Booleans accept true / false, or 1 / 2 interactively. Other types use the displayed input hints; invalid values can be edited and retried. Terminal prompts use inquire, included in the existing operations-cli feature. Configuration keys, types, current values and hints use the existing terminal palette and respect color options such as NO_COLOR.
Interactive input follows the inquire editor. Validation receives the text returned by the library, rather than raw key bytes. In text and password prompts, pressing Tab does not append a character: typing ab, Tab, then cd produces abcd. Backspace and other editing keys are also handled by the library. This does not grant fields permission to store control characters; the resulting text must still pass the field’s validation. For literal input or multiline settings, use an explicit value, --value-stdin or --value-file and follow the setting’s format requirements.
Enter keeps an existing value without writing or publishing a reload notification. In config validate KEY, this validates the saved value and previews that setting; an invalid saved value still fails validation. If no saved value exists, the prompt asks again. Ctrl+C, Ctrl+D or Esc cancels and restores terminal state, prints Canceled. on its own line, and exits with status 130 instead of a validation error. Clearing requires --clear or an explicit empty string and still passes the setting’s validation:
./aster_drive config set branding_title --clear./aster_drive config set branding_title ''Interactive input requires terminal stdin and stderr; stdout can be redirected. Without a usable interactive terminal, missing keys or values fail immediately. Prompts go to stderr and stdout contains results only; use config --output-format json set branding_title for JSON. Explicit CLI arguments take precedence over ASTER_CLI_CONFIG_KEY / ASTER_CLI_CONFIG_VALUE. Duplicate keys or multiple value sources are rejected. Piped input still requires --value-stdin; use stdin or files for multiline values.
Automation can use stdin or a file with mode 0600:
printf '%s' 'smtp-secret' | ./aster_drive config --database-url "$DB_URL" set --key mail_smtp_password --value-stdin./aster_drive config --database-url "$DB_URL" set --key mail_smtp_password --value-file /run/secrets/smtp-passwordPositional values, explicit --value and ASTER_CLI_CONFIG_VALUE remain available, but may expose sensitive content in command arguments, shell history, or process diagnostics. Redacted CLI output cannot prevent exposure through those sources.
config export emits the single versioned JSON backup format accepted directly by import and validate --input-file. Sensitive values are omitted by default and listed under omitted_sensitive_keys. A complete restore requires --include-sensitive; its output contains plaintext credentials and must be protected as a secret file. Import files require mode 0600.
{ "format": "asterdrive.runtime-config", "version": 1, "configs": [{"key":"public_site_url","value":["https://drive.example.com"],"source":"system","visibility":"private","is_sensitive":false}], "omitted_sensitive_keys": ["mail_smtp_password"]}Import example:
./aster_drive config \ --database-url "sqlite:///var/lib/asterdrive/data/asterdrive.db?mode=rwc" \ import \ --input-file ./runtime-config.jsonExport existing config like this:
./aster_drive config \ --database-url "sqlite:///var/lib/asterdrive/data/asterdrive.db?mode=rwc" \ --output-format pretty-json \ exportImport validates every entry before writing the complete file in one transaction. Failure leaves no partial changes. Settings absent from the backup keep their target values. Only the current versioned backup format is accepted; display output and older key/value arrays are not restorable inputs.
System entries must exist in the current registry; their source, visibility, and is_sensitive metadata are read-only. Custom entries must explicitly use custom. Duplicate keys, unknown system keys, redacted placeholders, and display-only fields are rejected. Sensitive entries must remain private, and imports cannot remove existing sensitivity. Reload notifications are sent only after commit; if delivery fails, the error states that settings were saved and asks you to check config_sync or restart the affected instances.
Set a restrictive umask such as umask 077 before redirecting an export that includes secrets.
If you only want to confirm whether a value is valid, prefer validate. Do not use set directly.
Follower Node Enrollment: node enroll
Section titled “Follower Node Enrollment: node enroll”This command is only for follower nodes. After the primary admin panel generates an enrollment token, run this on the follower machine:
./aster_drive node enroll \ --master-url https://drive.example.com \ --token-promptYou can also run ./aster_drive node enroll https://drive.example.com, or omit the URL and enter it visibly before the hidden token prompt. Invalid interactive values can be edited and retried; cancellation happens before configuration initialization or enrollment requests. Existing --master-url scripts remain supported.
Interactive token input shows asterisks while typing and has no plaintext reveal toggle. Automation can use --token-stdin, --token-file, or ASTER_CLI_ENROLLMENT_TOKEN. Explicit URL and token sources override their environment defaults; missing noninteractive input fails immediately. Explicit --token exposes it in process arguments.
If you do not pass the database URL explicitly, the command reads [database].url from the current data/config.toml. You can also specify it directly:
./aster_drive node enroll \ --master-url https://drive.example.com \ --token-file /run/secrets/enrollment-token \ --database-url "sqlite:///var/lib/asterdrive/data/asterdrive.db?mode=rwc"It performs these steps:
- confirms the current config is
[server].start_mode = "follower" - if the current directory has no config file, generates a default
data/config.tomlin follower mode first - exchanges the token with the primary for local binding information, and writes it into the follower database
- outputs the current listen address, config file path, and next connectivity check hints
The command does not create a primary-managed remote storage target or start the HTTP service. After it succeeds, restart the follower process, create a target from the primary admin panel, and select it explicitly in the remote storage policy.
For Docker followers, using startup environment variables to auto-enroll is recommended instead of entering the container manually to run this command. See Docker Follower Node Deployment.
Offline Password Hashing
Section titled “Offline Password Hashing”./aster_drive hash-password prompts for masked input in an interactive terminal and writes only the resulting hash to stdout; prompts go to stderr. Piped input remains supported. Passwords must contain 1–4096 UTF-8 bytes without control characters. Invalid interactive input can be edited and retried; cancellation does not load instance configuration or initialize a database.
Cross-Database Migration: database-migrate
Section titled “Cross-Database Migration: database-migrate”This command is for “switching database backends”.
It is not the automatic schema migration that runs during normal startup. It copies existing business data from one database to another.
Common scenarios:
- SQLite to PostgreSQL
- SQLite to MySQL
- switching between PostgreSQL and MySQL
Recommended sequence:
- Run
--dry-runfirst. - Prepare a downtime window so the source database is not written during migration.
- Run the real migration.
- Only cut production over to the new database after
ready_to_cutover = true.
Trial run:
./aster_drive database-migrate \ --source-database-url "sqlite:///var/lib/asterdrive/data/asterdrive.db?mode=rwc" \ --target-database-url "postgres://user:password@127.0.0.1:5432/asterdrive_new" \ --dry-runReal run:
./aster_drive database-migrate \ --source-database-url "sqlite:///var/lib/asterdrive/data/asterdrive.db?mode=rwc" \ --target-database-url "postgres://user:password@127.0.0.1:5432/asterdrive_new"Verify target database only:
./aster_drive database-migrate \ --source-database-url "sqlite:///var/lib/asterdrive/data/asterdrive.db?mode=rwc" \ --target-database-url "postgres://user:password@127.0.0.1:5432/asterdrive_new" \ --verify-onlyThis command currently handles:
- checking migration state for source and target databases
- automatically bringing the target schema up to the current version
- copying business tables in a fixed order
- validating row counts, unique constraints, and foreign keys
- writing checkpoints into the target database so the same command can resume after interruption
Remember three things when using it:
- The source database must already be at the “current schema”; pending migrations cause immediate refusal.
- Do not continue writing new data into the source database during migration.
- Only
ready_to_cutover = truein the report means the target database is ready for switching.
Preflight accepts empty legacy storage_policy_credentials and storage_connector_application_configs tables without copying them. Nonempty legacy tables or old static policy credentials block migration with guidance to finish importing credentials on 0.5.x first. Other unknown tables remain rejected.
When to Read This Page First
Section titled “When to Read This Page First”- Deployment is complete, but you are not ready to launch confidently.
- The admin panel cannot open, and you urgently need to inspect configuration.
- A follower node has an enrollment token and needs to enroll from the shell.
- You are preparing to move from SQLite to PostgreSQL / MySQL.
- You want to turn checks into scripts.