benbjohnson/litestream · error

no SQLite databases found in directory %s with pattern %s

Error message

no SQLite databases found in directory %s with pattern %s

What it means

The directory scan succeeded but matched zero SQLite databases. Litestream refuses to run directory replication with nothing to replicate — unless Watch mode is enabled, in which case it will keep monitoring for databases appearing later. The error includes both the directory and the pattern to help diagnose glob mistakes.

Source

Thrown at cmd/litestream/main.go:839

		return nil, fmt.Errorf("pattern is required for directory replication")
	}
	if dbc.MetaPath != nil && dbc.MetaDir != nil {
		return nil, fmt.Errorf("cannot specify both 'meta-path' and 'meta-dir'")
	}

	dirPath, err := expand(dbc.Dir)
	if err != nil {
		return nil, err
	}

	// Find all SQLite databases in the directory
	dbPaths, err := FindSQLiteDatabases(dirPath, dbc.Pattern, dbc.Recursive)
	if err != nil {
		return nil, fmt.Errorf("failed to scan directory %s: %w", dirPath, err)
	}

	if len(dbPaths) == 0 && !dbc.Watch {
		return nil, fmt.Errorf("no SQLite databases found in directory %s with pattern %s", dirPath, dbc.Pattern)
	}

	// Create DB instances for each found database
	var dbs []*litestream.DB
	metaPaths := make(map[string]string)

	for _, dbPath := range dbPaths {
		db, err := newDBFromDirectoryEntry(dbc, dirPath, dbPath)
		if err != nil {
			return nil, fmt.Errorf("failed to create DB for %s: %w", dbPath, err)
		}

		// Validate unique meta-path to prevent replication state corruption
		if mp := db.MetaPath(); mp != "" {
			if existingDB, exists := metaPaths[mp]; exists {
				return nil, fmt.Errorf("meta-path collision: databases %s and %s would share meta-path %s, causing replication state corruption", existingDB, dbPath, mp)
			}
			metaPaths[mp] = dbPath

View on GitHub (pinned to 4ed7a308f6)

Solutions

  1. Verify the directory actually contains SQLite files: ls the path and compare with the pattern.
  2. Broaden or correct the pattern (e.g. `*.db*` or `**/*.sqlite*`); remember globs are case-sensitive on Linux.
  3. Set `watch: true` in the db config if databases may be created after litestream starts.
  4. Confirm you pointed at the right directory (expanded env vars, correct container mount).

Example fix

# before
dbs:
  - dir: /data
    pattern: "*.sqlite"

# after (files are actually app1.db, app2.db)
dbs:
  - dir: /data
    pattern: "*.db"
    watch: true
Defensive patterns

Strategy: validation

Validate before calling

matches, err := filepath.Glob(pattern)
if err == nil && len(matches) == 0 {
    return fmt.Errorf("pattern %q matches nothing in %s", pattern, dirPath)
}

Prevention

When it happens

Trigger: NewDBsFromDirectoryConfig with Watch=false and FindSQLiteDatabases returning an empty slice — pattern matches no files in dirPath.

Common situations: Pattern doesn't match actual extensions (`*.sqlite` vs `.sqlite3` or `.db`); wrong directory path; databases haven't been created yet at startup; case-sensitivity mismatch on the glob.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of benbjohnson/litestream@4ed7a308f6 (2026-09-06). Data as JSON: /api/errors/e8ef294e006f95e0. Report an issue: GitHub.