{"record":{"id":"da0182746ecf8255","repo":"MuntashirAkon/AppManager","slug":"could-not-get-backup-files","errorCode":null,"errorMessage":"Could not get backup files.","messagePattern":"Could not get backup files\\.","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupManager.java","lineNumber":116,"sourceCode":"        }\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;\n        if (options.relativeDirs == null) {\n            // Delete base backup\n            Backup baseBackup = BackupUtils.retrieveBaseBackupFromDb(options.userId, options.packageName);\n            if (baseBackup != null) {","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupManager.java#L98-L134","documentation":"In restore(), when resolving the BackupItem (from relativeDir or the base backup), an IOException can occur while touching the backup files; it is wrapped and rethrown as BackupException('Could not get backup files.', e). It signals I/O trouble reading the backup directory/metadata — typically missing, unreadable, or moved files.","triggerScenarios":"restore() with a relativeDir whose files are missing/unreadable, or a base backup whose getItem() throws IOException because the underlying files were deleted or the storage is unavailable.","commonSituations":"Backup stored on external/SD storage that is unmounted; backup directory renamed or moved; files deleted by a cleaner app; permission issues on /storage after reboot; pointing at a relativeDir that doesn't exist.","solutions":["Check the cause (getCause()) to see the underlying IOException and path.","Verify the backup directory exists and is readable under the app's backup location.","Re-mount/enable access to the storage volume holding the backup; move backups to internal storage if external access is flaky.","Recreate the backup if the files are gone; catch BackupException and inform the user the backup is unusable."],"exampleFix":"// before\nmanager.restore(options, progress); // fails silently on bad path\n// after\ntry {\n    manager.restore(options, progress);\n} catch (BackupException e) {\n    Log.e(TAG, \"Backup files unreadable\", e.getCause());\n}","handlingStrategy":"try-catch","validationCode":"File dir = options.relativeDir != null ? new File(backupRoot, options.relativeDir) : null;\nif (dir != null && (!dir.exists() || !dir.canRead())) {\n    throw new IllegalStateException(\"Backup files missing/unreadable: \" + dir);\n}","typeGuard":"boolean backupReadable(String relDir) {\n    File d = new File(backupRoot, relDir);\n    return d.isDirectory() && d.canRead() && d.list().length > 0;\n}","tryCatchPattern":"try {\n    manager.restore(options, progress);\n} catch (BackupException e) {\n    if (\"Could not get backup files.\".equals(e.getMessage())) {\n        IOException io = (IOException) e.getCause(); // inspect path\n    }\n}","preventionTips":["Verify storage volume is mounted before restore ops","Keep backups on stable internal storage when possible","Log e.getCause() to identify the failing path"],"tags":["android","backup","restore","io","file-not-found"],"backgroundTag":"file-read-failed","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"}