{"record":{"id":"2184edd31f92f7f2","repo":"portainer/portainer","slug":"unable-to-determine-restored-database-version-err","errorCode":null,"errorMessage":"unable to determine restored database version. err: %w","messagePattern":"unable to determine restored database version\\. err: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/datastore/backup.go","lineNumber":77,"sourceCode":"func (store *Store) RestoreFromFile(backupFilename string) error {\n\tif err := store.Close(); err != nil {\n\t\treturn err\n\t}\n\n\tif err := store.fileService.Copy(backupFilename, store.connection.GetDatabaseFilePath(), true); err != nil {\n\t\treturn fmt.Errorf(\"unable to restore backup file %q. err: %w\", backupFilename, err)\n\t}\n\n\tlog.Info().Str(\"from\", backupFilename).Str(\"to\", store.connection.GetDatabaseFilePath()).Msgf(\"database restored\")\n\n\tif _, err := store.Open(); err != nil {\n\t\treturn fmt.Errorf(\"unable to determine version of restored portainer backup file: %w\", err)\n\t}\n\n\t// determine the db version\n\tversion, err := store.VersionService.Version()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to determine restored database version. err: %w\", err)\n\t}\n\n\teditionLabel := portainer.SoftwareEdition(version.Edition).GetEditionLabel()\n\tlog.Info().Msgf(\"Restored database version: Portainer %s %s\", editionLabel, version.SchemaVersion)\n\treturn nil\n}\n\nfunc (store *Store) createBackupPath() error {\n\tbackupDir := filesystem.JoinPaths(store.connection.GetStorePath(), \"backups\")\n\tif exists, _ := store.fileService.FileExists(backupDir); !exists {\n\t\tif err := os.MkdirAll(backupDir, 0o700); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to create backup folder: %w\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/portainer/portainer/blob/17e74456ff6e794b9d5439ec3fa06922aa18a3f8/api/datastore/backup.go#L59-L95","documentation":"Error \"unable to determine restored database version. err: %w\" thrown in portainer/portainer.","triggerScenarios":"Thrown at api/datastore/backup.go:77 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"17e74456ff6e794b9d5439ec3fa06922aa18a3f8","analyzedAt":"2026-08-26T23:09:01.915Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}