📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

Run a Daily TiDB Cloud CLI Workflow



This example follows a typical operator workflow across TiDB Cloud Starter and TiDB Cloud Filesystem.

Prerequisites

  • Install ti and run ti configure.
  • Ensure your organization has capacity for one TiDB Cloud Starter instance and one Filesystem.

Step 1. Inspect current resources

ti db list-db-clusters --db-cluster-type starter --output text ti fs list-file-systems --output text

Step 2. Create a TiDB Cloud Starter instance

ti db create-db-cluster \ --db-cluster-type starter \ --db-cluster-name daily-demo \ --dry-run export DB_CLUSTER_ID="$(ti db create-db-cluster \ --db-cluster-type starter \ --db-cluster-name daily-demo \ --wait \ --query id \ --output text)"

The command saves the returned cluster ID in DB_CLUSTER_ID. Because --wait was set, the create command returns after the cluster is active. You can inspect it again later:

ti db describe-db-cluster \ --db-cluster-id "$DB_CLUSTER_ID" \ --output text

Step 3. Verify SQL access

ti db create-db-sql-users --db-cluster-id "$DB_CLUSTER_ID" ti db execute-sql-statement \ --db-cluster-id "$DB_CLUSTER_ID" \ --read-only \ --sql "SELECT CURRENT_TIMESTAMP AS checked_at" \ --output text

Step 4. Create and use a Filesystem

export TI_FS_FILE_SYSTEM_ID="$(ti fs create-file-system \ --wait \ --query file_system_id \ --output text)" printf 'daily workflow\n' | ti fs copy-file \ --from-stdin \ --to-remote /notes/today.txt ti fs list-files \ --path /notes \ --output text

The file in /notes/today.txt verifies that the explicitly selected resource is usable.

Step 5. Check for updates

Check whether a newer version is available without changing the installed version:

ti update --check

Preview an update:

ti update --dry-run

If another workflow has an active Filesystem or Vault mount, stop writers and unmount it before applying the update so that ti and the Filesystem runtime are updated together. For instructions, see Update TiDB Cloud CLI.

Apply the update when appropriate:

ti update

Cleanup

ti fs delete-file-system \ --file-system-id "$TI_FS_FILE_SYSTEM_ID" ti db delete-db-cluster \ --db-cluster-id "$DB_CLUSTER_ID"

Security notes

  • Do not echo FS tokens or formatted database connection strings.
  • Use unique automation prefixes and delete only resources created by that run.
  • Preview destructive operations with --dry-run.

What's next

Was this page helpful?