# Back up SQLite in a scheduled job

Run the foreground command on the host that holds the SQLite files, using the same credentials as the scheduled task.

For a recurring schedule on fresh workers, choose **Multiple machines** in
**Machines → Add machine**. A successful join spends one token use for
the entire glob, even if a file later fails. A previously joined session
reuses its saved identity.

```bash
litebackup backup '/data/exports/**/*.sqlite' scheduled/ --timeout 30m
```

Each matched file takes its writer lock, captures committed SQLite pages and waits for acknowledgement. A failed file produces an error and the job continues with other matches. A nonzero exit means the job failed. An overlapping writer gets `busy`. Files already published remain available to restore.

```ts
import { Litebackup } from "@litebackup/sdk";

const litebackup = new Litebackup();

await litebackup.backups.once("/data/exports/**/*.sqlite", {
  prefix: "scheduled/",
  timeout: "30m",
});
```

A job exits nonzero when no files match or any file fails. The foreground process exits after cleanup. Use `litebackup start` for applications that need ongoing listing and uploads.

[Runnable TypeScript example](https://github.com/litebackup/sdk/blob/v1.11.0/typescript/examples/one-shot.ts) · [Cron](/sdk-sqlite-cron-backup) · [Temporal](/sdk-sqlite-temporal)

[SDK guides](/sdk-guides) · [Source on GitHub](https://github.com/litebackup/sdk/blob/v1.11.0/docs/sqlite-backup-script.md)
