result.deleteOnExit();
ZipOutputStream zipOut = new ZipOutputStream(new BufferedOutputStream(
new FileOutputStream(result)));
zipOut.setLevel(9);
ExternalResourceManager extMgr = ExternalResourceManager.getInstance();
// copy all the files from the existing backup into the externalized
// backup (but skip any files that appear to be externalized)
ZipEntry e;
while ((e = zipIn.getNextEntry()) != null) {
String filename = e.getName();
if (extMgr.isArchivedItem(filename))
continue;
ZipEntry eOut = new ZipEntry(filename);
eOut.setTime(e.getTime());
zipOut.putNextEntry(eOut);
FileUtils.copyFile(zipIn, zipOut);
zipOut.closeEntry();
}
zipIn.close();
// now, ask the external resource manager to augment the ZIP.
extMgr.addExternalResourcesToBackup(zipOut);
zipOut.finish();
zipOut.close();
return result;
}