MuntashirAkon/AppManager · error · BackupException
Could not retrieve metadata from backup.
Error message
Could not retrieve metadata from backup.
What it means
In deleteBackup(), after resolving each BackupItem, its metadata is read via backupItem.getMetadata(); an IOException is rethrown as BackupException('Could not retrieve metadata from backup.', e). This means the backup directory exists but its metadata file (e.g. the .backup-metadata or versioned metadata file) is missing or unreadable.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/BackupManager.java:156
throw new BackupException("Could not get backup files.", e);
}
} else backupItemList = Collections.emptyList();
} else {
backupItemList = new ArrayList<>(options.relativeDirs.length);
for (String relativeDir : options.relativeDirs) {
try {
backupItemList.add(BackupItems.findBackupItem(relativeDir));
} catch (IOException e) {
throw new BackupException("Could not get backup files.", e);
}
}
}
for (BackupItems.BackupItem backupItem : backupItemList) {
BackupMetadataV5 metadata;
try {
metadata = backupItem.getMetadata();
} catch (IOException e) {
throw new BackupException("Could not retrieve metadata from backup.", e);
}
if (!backupItem.isFrozen() && !backupItem.delete()) {
throw new BackupException("Could not delete the selected backups");
}
BackupUtils.deleteBackupToDbAndBroadcast(ContextUtils.getContext(), metadata);
}
}
public void verify(@NonNull String relativeDir) throws BackupException {
BackupItems.BackupItem backupItem;
try {
backupItem = BackupItems.findBackupItem(relativeDir);
} catch (IOException e) {
throw new BackupException("Could not get backup files.", e);
}
try (VerifyOp restoreOp = new VerifyOp(backupItem)) {
restoreOp.verify();
}View on GitHub (pinned to 0152f468fc)
Solutions
- Inspect the backup directory for the metadata file and restore it from a full copy of the backup.
- If metadata is unrecoverable, delete the directory manually (file manager/root) instead of via deleteBackup(), then prune the DB entry.
- Re-run the backup to regenerate a valid directory, then delete it cleanly.
- Catch BackupException and check getCause() to identify the corrupt path.
Example fix
// before
metadata = backupItem.getMetadata(); // throws if metadata file missing
// after
try {
metadata = backupItem.getMetadata();
} catch (IOException e) {
// fall back to manual removal
new File(backupRoot, relativeDir).deleteRecursively();
return;
} Defensive patterns
Strategy: try-catch
Validate before calling
File meta = new File(backupRoot, relDir, ".backup-metadata"); // version-appropriate name
if (!meta.exists()) {
throw new IllegalStateException("Metadata missing for " + relDir);
} Type guard
boolean hasMetadata(String relDir) {
File d = new File(backupRoot, relDir);
return d.isDirectory() && Objects.requireNonNull(d.list()).length > 1;
} Try / catch
try {
manager.deleteBackup(options);
} catch (BackupException e) {
if (e.getMessage().contains("metadata")) {
// metadata corrupt: remove dir manually + prune DB
}
} Prevention
- Avoid interrupting backups mid-write; check completion status before deleting
- Exclude backup dirs from cleaner apps
- Restore metadata from a full backup copy when available
When it happens
Trigger: deleteBackup() on a backup directory whose metadata file is absent, corrupted, or on unreadable storage — thrown from the getMetadata() call in the delete loop.
Common situations: Partial/aborted backup leaves a directory without metadata; cleaner apps deleted the metadata file; corrupted external storage; manually copied backup dirs that lost hidden/metadata files.
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
- Failed to write metadata.
- Failed to write metadata.
- Could not get backup files.
- Could not delete the selected backups
- Failed to setup metadata.
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/627b8d4c5aff23ae.
Report an issue: GitHub.