{"record":{"id":"73d4b8297f3280fe","repo":"benbjohnson/litestream","slug":"timestamp-does-not-exist","errorCode":null,"errorMessage":"timestamp does not exist","messagePattern":"timestamp does not exist","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"replica.go","lineNumber":590,"sourceCode":"\t\tif err != nil {\n\t\t\treturn time.Time{}, fmt.Errorf(\"v0.3.x time bounds: %w\", err)\n\t\t}\n\t\t// Extend time bounds to include v0.3.x backups.\n\t\tif !v3CreatedAt.IsZero() && (createdAt.IsZero() || v3CreatedAt.Before(createdAt)) {\n\t\t\tcreatedAt = v3CreatedAt\n\t\t}\n\t\tif !v3UpdatedAt.IsZero() && (updatedAt.IsZero() || v3UpdatedAt.After(updatedAt)) {\n\t\t\tupdatedAt = v3UpdatedAt\n\t\t}\n\t}\n\n\t// Skip if it does not contain timestamp.\n\tif !opt.Timestamp.IsZero() {\n\t\tif createdAt.IsZero() && updatedAt.IsZero() {\n\t\t\treturn time.Time{}, fmt.Errorf(\"no backups found\")\n\t\t}\n\t\tif opt.Timestamp.Before(createdAt) || opt.Timestamp.After(updatedAt) {\n\t\t\treturn time.Time{}, fmt.Errorf(\"timestamp does not exist\")\n\t\t}\n\t}\n\n\treturn updatedAt, nil\n}\n\n// Replica restores the database from a replica based on the options given.\n// This method will restore into opt.OutputPath, if specified, or into the\n// DB's original database path. It can optionally restore from a specific\n// replica or it will automatically choose the best one. Finally,\n// a timestamp can be specified to restore the database to a specific\n// point-in-time.\n//\n// When the replica contains both v0.3.x and LTX format backups, this method\n// compares snapshots from both formats and uses whichever has the better backup:\n// - With timestamp: uses the format with the most recent snapshot before timestamp\n// - Without timestamp: uses the format with the most recent backup overall\nfunc (r *Replica) Restore(ctx context.Context, opt RestoreOptions) (err error) {","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/replica.go#L572-L608","documentation":"When RestoreOptions.Timestamp is set and time bounds exist, CalcRestoreTarget validates that the requested timestamp falls within [createdAt, updatedAt] of the available backups. If the timestamp is earlier than the oldest backup or later than the newest, this error is returned. It means litestream cannot guarantee a consistent restore at that point in time.","triggerScenarios":"Calling restore with a -timestamp outside the replicated range: e.g. a time before the first LTX file was ever uploaded, or a future/clock-skewed time after the latest backup.","commonSituations":"Restoring to a time from before the replica existed; host clock skew producing future timestamps; timezone confusion (passing local time where UTC is expected); asking for a moment after replication stopped.","solutions":["Run `litestream ltx` (or query the restore target) to see the available time range and pick a timestamp inside it.","Check for clock skew/timezone issues and specify the timestamp in UTC.","If you need an earlier point than the oldest backup, restore to the oldest available timestamp or use another replica/snapshot.","Ensure replication is current if you intended a recent timestamp — trigger a sync and retry."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"target, err := replica.CalcRestoreTarget(ctx, litestream.RestoreOptions{Timestamp: ts})\nif err != nil {\n    return fmt.Errorf(\"timestamp %s not restorable: %w\", ts, err)\n}\n// target (updatedAt) is a valid restore point — use it","typeGuard":null,"tryCatchPattern":"err := replica.Restore(ctx, opt)\nif err != nil && strings.Contains(err.Error(), \"timestamp does not exist\") {\n    // clamp requested time to [createdAt, updatedAt] and retry\n}","preventionTips":["Query the restore target first to discover the valid time range","Specify timestamps in UTC to avoid timezone mistakes","Keep replication current and hosts clock-synced (NTP)"],"tags":["restore","timestamp","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}