MuntashirAkon/AppManager · error · BackupException

Could not finalise backup.

Error message

Could not finalise backup.

What it means

Finally, mBackupItem.commit() finalises the backup (renames staging into place, etc.). An IOException there means the backup could not be committed, wrapped as BackupException("Could not finalise backup."). Without a successful commit the backup remains incomplete.

Solutions

  1. Delete any leftover partial backup directory with the same name and retry
  2. Verify storage is mounted and writable during commit
  3. Check getCause() IOException for the exact filesystem error
  4. Retry the conversion with sufficient free space
Defensive patterns

Strategy: try-catch

Validate before calling

File target = new File(backupDir, packageName);
if (target.exists()) {
    // remove stale partial backup so commit() can succeed
    Utils.deleteDir(target);
}

Try / catch

try {
    converter.convert();
} catch (BackupException e) {
    if ("Could not finalise backup.".equals(e.getMessage())) {
        // clean partial backup dir and retry
    }
}

Prevention

When it happens

Trigger: BackupItem.commit() throws IOException — staging directory cannot be renamed/moved to the final backup path, target already exists in a bad state, or filesystem error.

Common situations: Target backup name collision; storage unmounted mid-operation; leftover partial backup from a previous failed run blocking commit.

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

Appendix: source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/convert/OABConverter.java:159

                for (Map.Entry<String, String> filenameChecksumPair : filenameChecksumMap.entrySet()) {
                    mChecksum.add(filenameChecksumPair.getKey(), filenameChecksumPair.getValue());
                }
            } catch (IOException e) {
                throw new BackupException("Failed to write metadata.", e);
            }
            // Store checksum for metadata
            mChecksum.close();
            // Encrypt checksum
            try {
                mBackupItem.encrypt(new Path[]{mChecksum.getFile()});
            } catch (IOException e) {
                throw new BackupException("Failed to encrypt checksums.txt", e);
            }
            // Replace current backup
            try {
                mBackupItem.commit();
            } catch (IOException e) {
                throw new BackupException("Could not finalise backup.", e);
            }
            backupSuccess = true;
        } catch (BackupException e) {
            throw e;
        } catch (Throwable th) {
            throw new BackupException("Unknown error occurred.", th);
        } finally {
            mBackupItem.cleanup();
            if (backupSuccess) {
                BackupUtils.putBackupToDbAndBroadcast(ContextUtils.getContext(), mDestMetadata);
            }
        }
    }

    @Override
    public void cleanup() {
        mSourceCrypto.close();
        mBackupLocation.delete();

View on GitHub (pinned to 0152f468fc)