MuntashirAkon/AppManager · error · BackupException

Could not backup data

Error message

Could not backup data

What it means

backupData() wraps the whole decompress->retar->encrypt/checksum pipeline in a try block; any IOException (read failure on the source archive, disk full, write failure to split outputs, encryption I/O errors) is rethrown as BackupException("Could not backup data", e). It is the generic failure point of the TB conversion's data-copy stage.

Source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/convert/TBConverter.java:368

            }

            // Encrypt created backups and generate checksum
            if (intSos != null) {
                // Encrypt backups
                Path[] newBackupFiles = mBackupItem.encrypt(intSos.getFiles().toArray(new Path[0]));
                for (Path file : newBackupFiles) {
                    mChecksum.add(file.getName(), DigestUtils.getHexDigest(mDestMetadata.info.checksumAlgo, file));
                }
            }
            if (extSos != null) {
                // Encrypt backups
                Path[] newBackupFiles = mBackupItem.encrypt(extSos.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("Could not backup data", e);
        }
    }

    private BackupMetadataV2 readPropFile() throws BackupException {
        try (InputStream is = mPropFile.openInputStream()) {
            BackupMetadataV2 metadataV2 = new BackupMetadataV2();
            Properties prop = new Properties();
            prop.load(is);
            metadataV2.label = prop.getProperty("app_label");
            metadataV2.packageName = mPackageName;
            metadataV2.versionName = prop.getProperty("app_version_name");
            metadataV2.versionCode = Integer.parseInt(prop.getProperty("app_version_code"));
            metadataV2.isSystem = "1".equals(prop.getProperty("app_is_system"));
            metadataV2.isSplitApk = false;
            metadataV2.splitConfigs = ArrayUtils.emptyArray(String.class);
            metadataV2.hasRules = false;
            metadataV2.backupTime = mBackupTime;
            metadataV2.crypto = CryptoUtils.MODE_NO_ENCRYPTION;  // We only support no encryption mode for TB backups

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Inspect the cause chain (getCause()) for the underlying IOException; fix that specific issue.
  2. Free up storage space before converting; large app data can exceed available space.
  3. Verify the source tar is not truncated (compare checksums/size with the original backup).
  4. Re-check storage permissions and that the backup path is writable and mounted.

Example fix

// before
try { converter.convert(backupDir); }
catch (BackupException e) { Log.e(TAG, "failed"); }
// after
try { converter.convert(backupDir); }
catch (BackupException e) {
    Log.e(TAG, "convert failed", e); // read the wrapped IOException
    if (e.getCause() instanceof IOException && !hasFreeSpace(dir, requiredBytes)) {
        // prompt user to free space, then retry
    }
}
Defensive patterns

Strategy: try-catch

Validate before calling

long required = sourceTar.length() * 3L; // decompressed + retarred + encrypted estimate
if (new File(destPath).getUsableSpace() < required) throw new IllegalStateException("Not enough free space");

Try / catch

try {
    converter.convert(backupDir);
} catch (BackupException e) {
    Throwable cause = e.getCause();
    if (cause instanceof IOException) {
        Log.e(TAG, "Data backup I/O failed", cause); // inspect: disk full? permissions? corrupt tar?
    } else throw e;
}

Prevention

When it happens

Trigger: Any IOException inside backupData(): unreadable/corrupt source tar, storage full while writing SplitOutputStream segments, permission errors on the backup path, or failures while encrypting the produced split files.

Common situations: Insufficient free space on internal/external storage during large app data conversion; corrupted or truncated source .tar; SD card removed mid-operation; storage permission revoked; encryption key/keystore issues surfacing as I/O failures.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


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