MuntashirAkon/AppManager · error · BackupException

Failed to backup data directory at

Error message

Failed to backup data directory at 

What it means

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.

Source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupOp.java:374

                throw new BackupException("Failed to encrypt " + Arrays.toString(dataFiles));
            }
            for (Path file : dataFiles) {
                mChecksum.add(file.getName(), DigestUtils.getHexDigest(mMetadata.info.checksumAlgo, file));
            }
        }
    }

    @NonNull
    private Path[] backupDirectory(@NonNull String dir, int index) throws BackupException {
        String filePrefix = BackupUtils.getDataFilePrefix(index, getExt(mMetadata.info.tarType));
        try {
            return TarUtils.create(mMetadata.info.tarType, Paths.get(dir),
                            mBackupItem.getUnencryptedBackupPath(),
                            filePrefix, null, null,
                            BackupUtils.getExcludeDirs(!mBackupFlags.backupCache()), false)
                    .toArray(new Path[0]);
        } catch (Throwable th) {
            throw new BackupException("Failed to backup data directory at " + dir, th);
        }
    }

    @NonNull
    private Path[] backupAdb(int index) throws BackupException {
        try {
            String filePrefix = BackupUtils.getDataFilePrefix(index, ".ab");
            Path abFile = mBackupItem.getUnencryptedBackupPath().createNewFile(filePrefix, null);
            try (OutputStream os = abFile.openOutputStream()) {
                ParcelFileDescriptor fd = ParcelFileDescriptorUtil.pipeTo(os);
                BackupCompat.adbBackup(mUserId, fd, false, false, false,
                        false, false, false, false, true,
                        new String[]{mPackageName});
            }
            return new Path[]{abFile};
        } catch (Throwable th) {
            throw new BackupException("Failed to backup ADB data.", th);
        }

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Inspect the chained cause (getCause()) for the real I/O error
  2. Verify the data directory exists and is readable for the target user before running the backup
  3. Check available storage on the backup destination
  4. Re-run with backupCache flags adjusted so required dirs are not excluded

Example fix

// before
Path[] files = backupDirectory(index, dir); // throws BackupException
// after
try {
    Path[] files = backupDirectory(index, dir);
} catch (BackupException e) {
    Log.e(TAG, "Data backup failed for " + dir, e.getCause());
    // skip data item or abort backup gracefully
}
Defensive patterns

Strategy: try-catch

Validate before calling

java.io.File dir = new File(dataDir);
if (!dir.exists() || !dir.canRead()) throw new IllegalStateException("Data dir unreadable: " + dir);

Type guard

static boolean isReadableDir(Path p) {
    return p != null && Files.isDirectory(p) && Files.isReadable(p);
}

Try / catch

try {
    Path[] files = backupDirectory(index, dir);
} catch (BackupException e) {
    Log.e(TAG, "data backup failed: " + dir, e.getCause());
    // choose: abort or continue without data
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/e3500ed070614b2a. Report an issue: GitHub.