MuntashirAkon/AppManager · error · BackupException

Data restore is requested but there are no data files for in

Error message

Data restore is requested but there are no data files for index ${index}.

What it means

restoreDirectory, invoked per data directory, requires the list of backup archive files for that index. If mBackupItem.getDataFiles(index) is empty, it throws this BackupException before touching the target directory. Unlike error 133 (raised during checksum verification), this fires even when signature checks are skipped.

Source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java:527

            String backupDataDir = mBackupMetadata.dataDirs[i];
            if (backupDataDir.equals(BackupManager.DATA_BACKUP_SPECIAL_ADB)) {
                // Adb backup restore
                restoreAdb(i);
            } else {
                // Regular directory restore
                restoreDirectory(mBackupMetadata.dataDirs[i], i);
            }
        }
    }

    private void restoreDirectory(@NonNull String dir, int index) throws BackupException {
        String dataSource = BackupUtils.getWritableDataDirectory(dir, mBackupInfo.userId, mUserId);
        BackupDataDirectoryInfo dataDirectoryInfo = BackupDataDirectoryInfo.getInfo(dataSource, mUserId);
        Path dataSourceFile = dataDirectoryInfo.getDirectory();

        Path[] dataFiles = mBackupItem.getDataFiles(index);
        if (dataFiles.length == 0) {
            throw new BackupException("Data restore is requested but there are no data files for index " + index + ".");
        }
        UidGidPair uidGidPair = dataSourceFile.getUidGid();
        if (uidGidPair == null) {
            // Fallback to app UID
            uidGidPair = new UidGidPair(mUid, mUid);
        }
        if (dataDirectoryInfo.isExternal()) {
            // Skip if external data restore is not requested
            switch (dataDirectoryInfo.subtype) {
                case BackupDataDirectoryInfo.TYPE_ANDROID_DATA:
                    // Skip restoring Android/data directory if not requested
                    if (!mRequestedFlags.backupExternalData()) {
                        return;
                    }
                    break;
                case BackupDataDirectoryInfo.TYPE_ANDROID_OBB:
                case BackupDataDirectoryInfo.TYPE_ANDROID_MEDIA:
                    // Skip restoring Android/data or Android/media if media/obb restore not requested

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Restore the missing data archive files for that index from the original backup source.
  2. Re-create the backup, ensuring it completes without interruption.
  3. Check file naming matches what BackupFiles.BackupItem.getDataFiles() expects (don't rename backup files).
  4. Remove the corresponding dataDirs entry from metadata if that data directory is intentionally absent.

Example fix

// before: restoring pruned backup
ew RestoreOp(...).runRestore(); // throws: no data files for index
// after: check per-index availability before restoring
if (backupItem.getDataFiles(0).length == 0) {
    restoreApkOnly(); // fall back instead of failing
} else {
    runRestore();
}
Defensive patterns

Strategy: validation

Validate before calling

int index = 0; // per directory
if (backupItem.getDataFiles(index).length == 0)
    throw new IllegalStateException("Missing data archives for index " + index);

Type guard

boolean indexPresent(BackupItem item, int index) { return item.getDataFiles(index).length > 0; }

Try / catch

try { runRestore(); } catch (BackupException e) {
    if (e.getMessage().contains("no data files for index")) {
        // fall back to app-only restore
        restoreWithoutData();
    } else throw e;
}

Prevention

When it happens

Trigger: Data archive files for the given index missing from the backup directory; index refers to a data dir whose files were deleted; restoring with skipSignatureCheck enabled so the earlier check (error 133) never ran; misnamed data files so getDataFiles finds none.

Common situations: Manual pruning of large .tar files to save space; interrupted backup that never wrote the archives; user renamed files breaking the expected naming pattern.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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