{"record":{"id":"e3500ed070614b2a","repo":"MuntashirAkon/AppManager","slug":"failed-to-backup-data-directory-at","errorCode":null,"errorMessage":"Failed to backup data directory at ","messagePattern":"Failed to backup data directory at ","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupOp.java","lineNumber":374,"sourceCode":"                throw new BackupException(\"Failed to encrypt \" + Arrays.toString(dataFiles));\n            }\n            for (Path file : dataFiles) {\n                mChecksum.add(file.getName(), DigestUtils.getHexDigest(mMetadata.info.checksumAlgo, file));\n            }\n        }\n    }\n\n    @NonNull\n    private Path[] backupDirectory(@NonNull String dir, int index) throws BackupException {\n        String filePrefix = BackupUtils.getDataFilePrefix(index, getExt(mMetadata.info.tarType));\n        try {\n            return TarUtils.create(mMetadata.info.tarType, Paths.get(dir),\n                            mBackupItem.getUnencryptedBackupPath(),\n                            filePrefix, null, null,\n                            BackupUtils.getExcludeDirs(!mBackupFlags.backupCache()), false)\n                    .toArray(new Path[0]);\n        } catch (Throwable th) {\n            throw new BackupException(\"Failed to backup data directory at \" + dir, th);\n        }\n    }\n\n    @NonNull\n    private Path[] backupAdb(int index) throws BackupException {\n        try {\n            String filePrefix = BackupUtils.getDataFilePrefix(index, \".ab\");\n            Path abFile = mBackupItem.getUnencryptedBackupPath().createNewFile(filePrefix, null);\n            try (OutputStream os = abFile.openOutputStream()) {\n                ParcelFileDescriptor fd = ParcelFileDescriptorUtil.pipeTo(os);\n                BackupCompat.adbBackup(mUserId, fd, false, false, false,\n                        false, false, false, false, true,\n                        new String[]{mPackageName});\n            }\n            return new Path[]{abFile};\n        } catch (Throwable th) {\n            throw new BackupException(\"Failed to backup ADB data.\", th);\n        }","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupOp.java#L356-L392","documentation":"BackupOp wraps any failure while archiving an app's data directory (via TarUtils.create) into a BackupException with the failing directory path appended. The original Throwable is preserved as the cause, so the root reason (I/O error, missing files, tar failure) is chained. It signals that the data portion of a backup could not be produced.","triggerScenarios":"backupDirectory() calls TarUtils.create(...) for a data dir and any Throwable from tar creation (unreadable files, IO errors, unsupported tarType) triggers this message with that dir.","commonSituations":"Data directory deleted or inaccessible mid-backup (app uninstalled, storage revoked); exclude-dir filter removing everything; storage full; selinux/permission restrictions on the app's data path.","solutions":["Inspect the chained cause (getCause()) for the real I/O error","Verify the data directory exists and is readable for the target user before running the backup","Check available storage on the backup destination","Re-run with backupCache flags adjusted so required dirs are not excluded"],"exampleFix":"// before\nPath[] files = backupDirectory(index, dir); // throws BackupException\n// after\ntry {\n    Path[] files = backupDirectory(index, dir);\n} catch (BackupException e) {\n    Log.e(TAG, \"Data backup failed for \" + dir, e.getCause());\n    // skip data item or abort backup gracefully\n}","handlingStrategy":"try-catch","validationCode":"java.io.File dir = new File(dataDir);\nif (!dir.exists() || !dir.canRead()) throw new IllegalStateException(\"Data dir unreadable: \" + dir);","typeGuard":"static boolean isReadableDir(Path p) {\n    return p != null && Files.isDirectory(p) && Files.isReadable(p);\n}","tryCatchPattern":"try {\n    Path[] files = backupDirectory(index, dir);\n} catch (BackupException e) {\n    Log.e(TAG, \"data backup failed: \" + dir, e.getCause());\n    // choose: abort or continue without data\n}","preventionTips":["Always log getCause() — the message omits the root error","Pre-check data dir existence/readability for the target user","Ensure sufficient free space on the destination","Pin down backupCache/exclude flags intentionally"],"tags":["backup","io","tar","android"],"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-14T16:17:12.679Z"}