{"record":{"id":"dbd8f729181f6cea","repo":"ory/hydra","slug":"newrestore-failed","errorCode":null,"errorMessage":"NewRestore failed","messagePattern":"NewRestore failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"oryx/popx/migrator.go","lineNumber":108,"sourceCode":"\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to acquire sql.Conn for restore\")\n\t}\n\tdefer func() { _ = conn.Close() }()\n\n\treturn conn.Raw(func(driverConn any) error {\n\t\tif w, ok := driverConn.(interface{ Raw() driver.Conn }); ok {\n\t\t\tdriverConn = w.Raw()\n\t\t}\n\t\trestorer, ok := driverConn.(interface {\n\t\t\tNewRestore(srcUri string) (*moderncsqlite.Backup, error)\n\t\t})\n\t\tif !ok {\n\t\t\treturn errors.Errorf(\"driver %T does not support online restore\", driverConn)\n\t\t}\n\t\t// See: https://sqlite.org/backup.html .\n\t\tbackup, err := restorer.NewRestore(srcPath)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"NewRestore failed\")\n\t\t}\n\t\t// Step(-1) copies all remaining pages in one call.\n\t\tfor {\n\t\t\tmore, stepErr := backup.Step(-1)\n\t\t\tif stepErr != nil {\n\t\t\t\t_ = backup.Finish()\n\t\t\t\treturn errors.Wrap(stepErr, \"backup.Step failed\")\n\t\t\t}\n\t\t\tif !more {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\treturn errors.Wrap(backup.Finish(), \"backup.Finish failed\")\n\t})\n}\n\n// UpTo runs up to step \"up\" migrations and applies them to the database.\n// If step <= 0 all pending migrations are run.","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/ory/hydra/blob/4174065ffb052799890f7480f5360a877a67ffc1/oryx/popx/migrator.go#L90-L126","documentation":"After obtaining a restorer via NewRestore(srcPath), a failure creating the backup handle is wrapped as 'NewRestore failed'. This wraps the driver-level error from initiating the SQLite online backup against the source URI.","triggerScenarios":"The source database path is invalid, unreadable, not a SQLite file, or locked; the driver refuses to open the source for backup.","commonSituations":"Restoring from a file that was deleted/moved; wrong srcPath passed to the restore routine; source file permissions blocking read; source DB corrupted or in WAL state the driver can't attach.","solutions":["Verify srcPath points to an existing, readable SQLite database file","Check file permissions and that no other process exclusively locks the source","Read the wrapped cause error for the underlying open failure","Test opening srcPath directly with sqlite to confirm validity"],"exampleFix":"// before\nrestoreSQLiteOnline(ctx, db, \"/data/backup.db\") // file missing\n// after\nif _, err := os.Stat(\"/data/backup.db\"); err != nil { return err }\nerr := restoreSQLiteOnline(ctx, db, \"/data/backup.db\")","handlingStrategy":"validation","validationCode":"// Verify the restore source before starting\ninfo, err := os.Stat(srcPath)\nif err != nil { return fmt.Errorf(\"restore source missing: %w\", err) }\nif info.Size() == 0 { return errors.New(\"restore source is empty\") }","typeGuard":null,"tryCatchPattern":"if err := restoreSQLiteOnline(ctx, db, srcPath); err != nil {\n  var wrapped interface{ Unwrap() error }\n  if errors.As(err, &wrapped) { log.Printf(\"restore cause: %v\", errors.Unwrap(err)) }\n  return err\n}","preventionTips":["Confirm srcPath exists and is a valid SQLite file before restore","Check file read permissions on the source","Quiesce writers on the source DB during restore","Keep backups on stable, non-volatile storage"],"tags":["sqlite","go","backup","filesystem"],"backgroundTag":"sqlite-backup-failed","analyzedSha":"4174065ffb052799890f7480f5360a877a67ffc1","analyzedAt":"2026-09-03T14:52:41.581Z","contentChangedAt":"2026-09-03T14:52:41.581Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}