MuntashirAkon/AppManager · error · BackupException

Backup failed for

Error message

Backup failed for 

What it means

Thrown by SBConverter.backupData when any IOException occurs while re-tarring a source data zip into the destination backup: reading the ZipInputStream, writing the split tar output, or encrypting the produced files. The offending data file is named in the message.

Source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/convert/SBConverter.java:264

                        if (tmpFile != null) {
                            // Copy from the temporary file
                            try (FileInputStream fis = new FileInputStream(tmpFile)) {
                                IoUtils.copy(fis, tos);
                            } finally {
                                FileCache.getGlobalFileCache().delete(tmpFile);
                            }
                        }
                        tos.closeArchiveEntry();
                    }
                    tos.finish();
                }
                // Encrypt backups
                Path[] newBackupFiles = mBackupItem.encrypt(sos.getFiles().toArray(new Path[0]));
                for (Path file : newBackupFiles) {
                    mChecksum.add(file.getName(), DigestUtils.getHexDigest(mDestMetadata.info.checksumAlgo, file));
                }
            } catch (IOException e) {
                throw new BackupException("Backup failed for " + dataFile, e);
            }
        }
    }

    @SuppressLint("WrongConstant")
    @NonNull
    private BackupMetadataV2 generateMetadata() throws BackupException {
        BackupMetadataV2 metadataV2 = new BackupMetadataV2();
        mCachedApk = FileUtils.getTempPath(mPackageName, "base.apk");
        try (InputStream pis = getApkFile().openInputStream()) {
            try (OutputStream fos = mCachedApk.openOutputStream()) {
                IoUtils.copy(pis, fos);
            }
            mFilesToBeDeleted.add(getApkFile());
        } catch (IOException e) {
            throw new BackupException("Could not cache APK file", e);
        }
        String filePath = Objects.requireNonNull(mCachedApk.getFilePath());

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Test the named data file with a zip utility; re-export the source archive if it is corrupt.
  2. Free up disk space or choose a destination with enough room for the uncompressed plus encrypted copies.
  3. Check write permissions on the destination path (especially external storage on Android 11+).
  4. Retry after confirming stable storage; transient I/O errors can abort the whole per-file loop.

Example fix

// before: assume zip is valid
zis.getNextEntry(); // IOException -> 'Backup failed for'
// after: validate archive first
try (ZipFile zf = new ZipFile(dataFile.getFilePath())) {
    if (zf.size() == 0) throw new IOException("empty archive");
}
// then proceed with conversion
Defensive patterns

Strategy: try-catch

Validate before calling

// validate the data archive is a readable zip before conversion
try (ZipInputStream zis = new ZipInputStream(new BufferedInputStream(
        new FileInputStream(dataZip)))) {
    if (zis.getNextEntry() == null)
        throw new IOException("empty or corrupt zip: " + dataZip);
}

Try / catch

try { converter.convert(); }
catch (BackupException e) {
    if (e.getMessage().startsWith("Backup failed for")) {
        Path bad = Path.of(e.getMessage().substring("Backup failed for ".length()));
        // validate/re-acquire bad file before retrying
    }
}

Prevention

When it happens

Trigger: Corrupt or non-zip data archive (ZipInputStream returns garbage/unexpected EOF), disk full in the destination split output, destination not writable, or encrypt() failing inside the same try-with-resources block.

Common situations: Interrupted downloads/copies leaving truncated data zips; converting large app data archives onto full storage; SD-card/USB backup destinations being unmounted mid-conversion; zip format changes in newer Swift Backup versions the converter can't parse.

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/f71f686cec190376. Report an issue: GitHub.