Airflow Catchup and Backfill
Catchup and backfill deal with past dates. Catchup decides whether Airflow creates runs for time periods that passed before the DAG started. Backfill lets you run a DAG for a chosen range of past dates on purpose. Both tools help when you add a new pipeline or fix old data.
The Missed Newspaper Picture
You go on holiday for a week and your newspapers pile up. When you return, you can read every missed paper in order, or you can read only today's paper. Catchup works like this choice. Catchup on means "read all missed papers". Catchup off means "read only the latest".
start_date = Jan 1 today = Jan 6 schedule = @daily catchup=True → runs for Jan 1, 2, 3, 4, 5 (all missed intervals) catchup=False → run for Jan 5 only (latest interval)
The Catchup Setting
from datetime import datetime
from airflow import DAG
with DAG(
dag_id="daily_sales",
start_date=datetime(2024, 1, 1),
schedule="@daily",
catchup=False,
) as dag:
...
Airflow 2 uses catchup=True as the default. Airflow 3 changes the default to False. State the setting in every DAG, so the behavior never depends on a default.
When Catchup Helps
- A report must exist for every day since a project start.
- Each run loads data for its own date, so old dates need processing.
When Catchup Hurts
- A DAG sends emails. A catchup of 90 days sends 90 emails at once.
- A DAG works with live data only. Old runs add no value.
Backfill: Running Past Dates on Purpose
A backfill creates runs for a date range that you choose. Use it after you fix a bug, add a new column, or load a new DAG that needs history.
Airflow 2 Command
airflow dags backfill \
--start-date 2024-01-01 \
--end-date 2024-01-07 \
daily_sales
Airflow 3 Command
airflow backfill create \
--dag-id daily_sales \
--from-date 2024-01-01 \
--to-date 2024-01-07
Newer versions also offer a Backfill option in the UI. Airflow 3 lets the scheduler manage backfills, which keeps them in the same queue as normal runs.
Backfill Flow
You choose a range: Jan 1 ─────────► Jan 7
│
▼
Airflow creates 7 runs, one per day
│
▼
Runs execute in order or in parallel, based on your limits
Rerunning Instead of Backfilling
Past runs that already exist do not need a backfill. Select the failed or finished tasks in the Grid view and choose Clear. Airflow runs them again for the same dates.
Control the Load
| Setting | Effect |
|---|---|
max_active_runs | Limits how many runs execute together |
depends_on_past | A task waits for the same task in the previous run to succeed |
pool | Limits tasks that share a resource |
A backfill of 365 days with no limits can overload a database. Set max_active_runs to a small number such as 2 or 3 first.
Why Idempotent Tasks Matter Here
A backfill may touch dates that already hold data. An idempotent task replaces the old result with the same new result. A task that only appends rows creates duplicates. Use the templated date {{ ds }} and delete-then-insert or upsert logic.
Safe Backfill Checklist
- Pause related downstream DAGs, so they do not read half-loaded data.
- Test one date with
airflow dags test. - Start with a small range, then widen it.
- Watch resource use in the UI.
Key Takeaways
- Catchup controls automatic runs for missed intervals.
- Backfill creates runs for a date range that you pick.
- Clearing tasks reruns existing runs.
- Idempotent tasks and run limits keep backfills safe.
