Access Airflow database
Each Airflow Deployment in Astro Private Cloud (APC) has its own metadata database. APC supports both PostgreSQL and MySQL as the database backend. You can connect to the database to run queries, troubleshoot issues, or perform maintenance tasks.
Database architecture
PostgreSQL
MySQL
Each Deployment has a single PostgreSQL database containing two schemas:
Retrieve the connection string
Each Deployment stores its database connection string in a Kubernetes secret named <release-name>-metadata. Run the following command to retrieve it:
This returns a connection URI in the following format:
PostgreSQL
MySQL
Connect to the database
Use kubectl exec
Run the following command to open an Airflow metadata database shell from the scheduler pod:
This command uses the Airflow metadata database connection that is already configured in the Deployment.
Connect from your local computer
If the database is accessible as a Kubernetes service, you can use kubectl port-forward to connect from your local computer. Identify the database service and namespace from the <host> field in the connection string, then forward the port:
PostgreSQL
MySQL
If PgBouncer is enabled, forward port 6543 from the PgBouncer service in the Deployment namespace instead.
Then connect using the credentials from the connection string:
If the database is an external service (for example, Amazon RDS or Google Cloud SQL), connect directly using the host and port from the connection string instead of port-forwarding.
Common queries
After you connect to the database, use the following queries to inspect Airflow metadata.
Dag information
Airflow 2.x
Airflow 3.x
Task instance status
Task failures
PostgreSQL
MySQL
External database configuration
To use an external database instead of the APC-managed database, create the Deployment using the upsertDeployment Houston API mutation with the following fields:
skipAirflowDatabaseProvisioning: Set totrueso Commander does not provision a database for this Deployment.metadataConnectionormetadataConnectionJson: The connection string or JSON object pointing to your external database.resultBackendConnectionorresultBackendConnectionJson: The connection string or JSON object for the Celery result backend.
For a complete example of the upsertDeployment mutation payload with external database configuration, see Bring your own Airflow database.
Back up and restore
For production environments, run backup and restore commands from your local computer or a dedicated admin computer. Do not run backup or restore commands from inside Airflow containers.
Before you run a backup, estimate the database size and confirm that your local computer has enough free disk space.
PostgreSQL
MySQL
Back up the database
PostgreSQL
MySQL
Restore the database
PostgreSQL
MySQL
Replace the placeholders with values from the connection string. See Retrieve the connection string.
Security best practices
Direct database access bypasses Airflow’s security model. Use with caution and only for troubleshooting or maintenance tasks.
- Use read-only access for monitoring.
- Never expose database ports publicly.
- Use SSL for all connections.
- Rotate credentials regularly.