{"record":{"id":"d515755b91d828d7","repo":"MuntashirAkon/AppManager","slug":"no-base-backup-found","errorCode":null,"errorMessage":"No base backup found.","messagePattern":"No base backup found\\.","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupManager.java","lineNumber":112,"sourceCode":"    public void restore(@NonNull RestoreOpOptions options, @Nullable ProgressHandler progressHandler)\n            throws BackupException {\n        if (options.packageName.equals(\"android\")) {\n            throw new BackupException(\"Android System (android) cannot be restored.\");\n        }\n        if (options.flags.isEmpty()) {\n            throw new BackupException(\"Restore is requested without any flags.\");\n        }\n        BackupItems.BackupItem backupItem;\n        try {\n            if (options.relativeDir != null) {\n                backupItem = BackupItems.findBackupItem(options.relativeDir);\n            } else {\n                // Use base backup\n                Backup baseBackup = BackupUtils.retrieveBaseBackupFromDb(options.userId, options.packageName);\n                if (baseBackup != null) {\n                    backupItem = baseBackup.getItem();\n                } else {\n                    throw new BackupException(\"No base backup found.\");\n                }\n            }\n        } catch (IOException e) {\n            throw new BackupException(\"Could not get backup files.\", e);\n        }\n        if (progressHandler != null) {\n            int max = calculateMaxProgress(options.flags);\n            progressHandler.setProgressTextInterface(ProgressHandler.PROGRESS_PERCENT);\n            progressHandler.postUpdate(max, 0f);\n        }\n        try (RestoreOp restoreOp = new RestoreOp(options.packageName, options.flags, backupItem, options.userId)) {\n            restoreOp.runRestore(progressHandler);\n            mRequiresRestart |= restoreOp.requiresRestart();\n        }\n    }\n\n    public void deleteBackup(@NonNull DeleteOpOptions options) throws BackupException {\n        List<BackupItems.BackupItem> backupItemList;","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupManager.java#L94-L130","documentation":"When RestoreOpOptions.relativeDir is null, restore() falls back to the 'base backup' recorded in the backup database for (userId, packageName). If BackupUtils.retrieveBaseBackupFromDb() returns null, there is no registered base backup, so the method throws BackupException('No base backup found.'). It means the backup metadata DB has no entry for that package/user.","triggerScenarios":"Calling restore() without options.relativeDir for a package that has no base-backup row in the database (never backed up with this app, DB wiped, or backup files exist on disk but were never registered).","commonSituations":"Restoring on a fresh install of AppManager where the backup DB is empty but old backup folders still exist in the backup directory; wrong userId passed so the DB lookup targets the wrong user; typo in packageName.","solutions":["Pass options.relativeDir pointing at the specific backup directory instead of relying on the base backup.","Re-import/register the existing backup folder so a base-backup entry is created in the DB.","Verify packageName and userId match the entry used when the backup was made.","Run a backup first (or use the UI's backup list) so a base backup exists, then restore."],"exampleFix":"// before\noptions.relativeDir = null; // relies on base backup\n// after\noptions.relativeDir = \"com.example.app/20240101_120000\"; // explicit backup dir\n","handlingStrategy":"validation","validationCode":"Backup base = BackupUtils.retrieveBaseBackupFromDb(userId, pkg);\nif (base == null) {\n    throw new IllegalStateException(\"No base backup for \" + pkg + \" user \" + userId + \"; specify relativeDir\");\n}","typeGuard":"boolean hasBaseBackup(int userId, String pkg) {\n    return BackupUtils.retrieveBaseBackupFromDb(userId, pkg) != null;\n}","tryCatchPattern":"try {\n    manager.restore(options, progress);\n} catch (BackupException e) {\n    if (e.getMessage().contains(\"No base backup\")) { /* fall back to explicit relativeDir */ }\n}","preventionTips":["Pass explicit relativeDir instead of relying on the base backup","Keep packageName/userId consistent with the backup-time values","Re-register backup folders after app reinstall so the DB is populated"],"tags":["android","backup","restore","database","not-found"],"backgroundTag":"record-not-found","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}