{"record":{"id":"0ea89efd08c56874","repo":"benbjohnson/litestream","slug":"no-backup-files-available","errorCode":null,"errorMessage":"no backup files available","messagePattern":"no backup files available","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"vfs.go","lineNumber":1260,"sourceCode":"\t// Start compaction monitors if enabled\n\tif f.compactor != nil && f.vfs != nil {\n\t\tf.startCompactionMonitors()\n\t}\n\n\treturn nil\n}\n\n// SetTargetTime rebuilds the page index to view the database at a specific time.\nfunc (f *VFSFile) SetTargetTime(ctx context.Context, timestamp time.Time) error {\n\tif timestamp.IsZero() {\n\t\treturn fmt.Errorf(\"target time required\")\n\t}\n\n\tinfos, err := CalcRestorePlan(ctx, f.client, 0, timestamp, f.logger)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot calc restore plan: %w\", err)\n\t} else if len(infos) == 0 {\n\t\treturn fmt.Errorf(\"no backup files available\")\n\t}\n\n\t// Disable hydrated reads during time travel - hydrated file is at latest state\n\tif f.hydrator != nil && f.hydrator.Complete() {\n\t\tf.hydrator.Disable()\n\t\tf.logger.Debug(\"hydration disabled for time travel\", \"target\", timestamp)\n\t}\n\n\treturn f.rebuildIndex(ctx, infos, &timestamp)\n}\n\n// ResetTime rebuilds the page index to the latest available state.\nfunc (f *VFSFile) ResetTime(ctx context.Context) error {\n\tinfos, err := CalcRestorePlan(ctx, f.client, 0, time.Time{}, f.logger)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot calc restore plan: %w\", err)\n\t} else if len(infos) == 0 {\n\t\treturn fmt.Errorf(\"no backup files available\")","sourceCodeStart":1242,"sourceCodeEnd":1278,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/vfs.go#L1242-L1278","documentation":"Returned by VFSFile.SetTargetTime when the computed restore plan contains zero LTX files, meaning the replica has no backup files that can represent the database at the requested timestamp. The library throws this because building a page index from an empty plan is impossible.","triggerScenarios":"CalcRestorePlan succeeds but returns no infos: the replica is empty, the target timestamp is before any existing snapshot, or all applicable LTX files were removed by retention/compaction.","commonSituations":"New replica not yet having completed its first snapshot; requesting time travel to a point older than the retention window; wrong bucket/path configured so no LTX files are visible.","solutions":["Pick a target timestamp within the replica's retention window (after the earliest snapshot)","Confirm the replica has any LTX files at all (litestream ltx listing) and that the client points at the right bucket/path","Re-replicate from the primary if the replica was wiped or retention deleted needed files"],"exampleFix":"// before\nfile.SetTargetTime(ctx, oldTime) // before earliest snapshot\n// after\nif earliest := replicas.EarliestTimestamp(); oldTime.Before(earliest) {\n    oldTime = earliest\n}\nfile.SetTargetTime(ctx, oldTime)","handlingStrategy":"validation","validationCode":"infos, err := client.LTXInfos(ctx)\nif err != nil || len(infos) == 0 { return errors.New(\"replica has no LTX files\") }","typeGuard":"func replicaHasBackups(infos []*ltx.FileInfo) bool { return len(infos) > 0 }","tryCatchPattern":"if err := file.SetTargetTime(ctx, t); err != nil {\n    if err.Error() == \"no backup files available\" {\n        return file.ResetTime(ctx) // or surface a clear user message\n    }\n    return err\n}","preventionTips":["Confirm the first replication snapshot completed before enabling time travel","Verify bucket/path config points at the replica that actually has files","Track retention windows so requested timestamps stay within coverage"],"tags":["time-travel","restore-plan","retention","empty"],"backgroundTag":"empty-result-set","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}