Skip to content

Scheduled Extractions

rust-sql-extractor supports cron-based scheduling for recurring data extraction runs.

Overview

Schedules allow you to define recurring extraction jobs that automatically run at specified times. Each schedule includes:

  • Name — human-readable label (e.g. "Nightly Full Sync")
  • Cron expression — standard 5-field cron timing
  • Table list — which tables to extract when the schedule fires
  • Enabled toggle — quickly pause/resume without deleting

Schedules are stored in schedules.json in the catalog directory, separate from the catalog itself.

Running Schedules

Via Web UI

When you start the server (sql-extractor start), the scheduler starts automatically in the background. Any enabled schedules will fire at their configured times.

Manage schedules through the 📅 Schedules button in the header toolbar.

Via Headless CLI

For server/container deployments without a browser:

# Run scheduler only (no web UI)
sql-extractor schedule --connection "$MSSQL_CONN"

# Run scheduler + API (manage schedules via REST)
sql-extractor schedule --api --port 8080

# With explicit paths
sql-extractor schedule --catalog-dir ./catalog --output ./output

Cron Expression Syntax

6-field format with seconds: second minute hour day-of-month month day-of-week

Field Values Special Characters
Second 0–59 * , - /
Minute 0–59 * , - /
Hour 0–23 * , - /
Day of Month 1–31 * , - /
Month 1–12 * , - /
Day of Week 0–6 (Sun=0) * , - /

Note: Unlike traditional Unix cron (5 fields), this uses a 6-field format with seconds first. This is required by the tokio-cron-scheduler library.

Common Patterns

Expression Meaning
0 0 9 * * * Daily at 9:00:00 AM
0 0 * * * * Every hour at :00:00
0 0 */6 * * * Every 6 hours
0 0 0 * * 0 Weekly on Sunday at midnight
0 0 0 1 * * Monthly on the 1st at midnight
0 30 2 * * 1-5 Weekdays at 2:30:00 AM
0 0 8,20 * * * Twice daily at 8:00 AM and 8:00 PM
0 */1 * * * * Every minute
*/30 * * * * * Every 30 seconds

REST API

All endpoints are prefixed with /api.

Method Endpoint Description
GET /schedules List all schedules
POST /schedules Create a new schedule
GET /schedules/:id Get a single schedule
PATCH /schedules/:id Update a schedule
DELETE /schedules/:id Delete a schedule
POST /schedules/:id/trigger Manually trigger a schedule

Create Schedule

POST /api/schedules
{
  "name": "Nightly Customer Sync",
  "cron_expression": "0 2 * * *",
  "tables": ["SalesLT.Customer", "SalesLT.SalesOrderHeader"]
}

Update Schedule

PATCH /api/schedules/1
{
  "enabled": false,
  "cron_expression": "0 3 * * *"
}

Manual Trigger

POST /api/schedules/1/trigger

Triggers the schedule's extraction immediately, regardless of the cron timing. Creates a normal extraction run.

Best Practices

  • Stagger schedules — avoid running multiple large extractions at the same time to reduce database load.
  • Use incremental strategies — tables configured with CDC, Change Tracking, or Watermark strategies extract faster than Full extracts.
  • Monitor runs — check the Runs modal or /api/runs endpoint for execution results.
  • Test your cron — use crontab.guru to validate expressions before saving.
  • Set a connection — schedules require an active database connection. For the headless CLI, pass --connection or set MSSQL_CONN.

Storage

Schedules persist to <catalog-dir>/schedules.json:

{
  "next_id": 3,
  "schedules": [
    {
      "id": 1,
      "name": "Nightly Full Sync",
      "enabled": true,
      "cron_expression": "0 2 * * *",
      "tables": [["SalesLT", "Customer"], ["SalesLT", "Product"]],
      "created_at": "2026-02-07T10:00:00Z",
      "last_run_at": "2026-02-07T02:00:00Z",
      "next_run_at": "2026-02-08T02:00:00Z"
    }
  ]
}

This file is separate from entries.json (catalog) and runs.json (run history) for clean separation of concerns.