clean

Definition

Purges old records from metastore tables.

Usage

$ airflow db clean [-h] --clean-before-timestamp CLEAN_BEFORE_TIMESTAMP
                 [--dry-run]
                 [--skip-archive]
                 [-t TABLES]
                 [-v]
                 [-y]

Arguments

Parameter Description

--clean-before-timestamp

Purge data created before the specified timestamp. If no timezone info is supplied, then the dates are assumed to be in Airflow default timezone. Example: 2022-01-01 00:00:00+01:00

--dry-run

Perform a dry run. Default: False

--skip-archive

Do not preserve purged records in an archive table. Default: False

-t, --tables

The names of the tables to be dropped. Accepts a comma-separated list. Possible values: callback_request, celery_taskmeta, celery_tasksetmeta, dag, dag_run, dataset_event, import_error, job, log, session, sla_miss, task_fail, task_instance, task_instance_history, task_reschedule, trigger, xcom

-y, --yes

Do not prompt to confirm. Default: False

-h, --help

Print out the help manual for this command

-v, --verbose

Make logging output more verbose

Examples

To purge records from the task_fail table, run:

$ airflow db clean --clean-before-timestamp 2025-04-03T12:42:04.284+0000 -t task_fail

Output example:

You have requested that we purge all data prior to 2025-04-03T12:42:04.284000+00:00 for tables ['task_fail'].
This is irreversible.  Consider backing up the tables first and / or doing a dry run with option --dry-run.
Enter 'delete rows' (without quotes) to proceed.
delete rows
Checking table task_fail
Found 1 rows meeting deletion criteria.
Performing Delete...
Moving data to table _airflow_deleted__task_fail__20250403043257
Finished Performing Delete
Found a mistake? Seleсt text and press Ctrl+Enter to report it