public static void packDatabase(DBHandle dbh, String itemName, String contentType,
			File outputFile, TaskMonitor monitor) throws CancelledException, IOException {
		synchronized (dbh) {
			if (isReadOnlyPDBDirectory(new ResourceFile(outputFile.getParentFile()))) {
				throw new ReadOnlyException(
					"Read-only DB directory lock, file creation not allowed: " + outputFile);
			}
			if (outputFile.exists()) {
				throw new DuplicateFileException(outputFile + " already exists");
			}
			boolean success = false;
			File tmpFile = null;
			try {
				tmpFile = Application.createTempFile("pack", ".tmp");
				tmpFile.delete();
				dbh.saveAs(tmpFile, false, monitor);
				try (InputStream itemIn = new BufferedInputStream(new FileInputStream(tmpFile))){
					ItemSerializer.outputItem(itemName, contentType, FolderItem.DATABASE_FILE_TYPE,
						tmpFile.length(), itemIn, outputFile, monitor);
				}
				success = true;
			}
			finally {
				tmpFile.delete();
				if (!success) {
					outputFile.delete();
				}
			}
		}
	}
Serialize (i.e., pack) an open database into the specified outputFile.
@param dbh open database handle
@param itemName name to associate with packed content
@param contentType supported DB content type
@param outputFile packed output file to be created
@param monitor save/pack monitor
@throws ReadOnlyException if {@code outputFile} location is write-protected
@throws DuplicateFileException if {@code outputFile} already exists
@throws IOException if IO error occurs
@throws CancelledException if monitor cancels operation
Ghidra/Framework/FileSystem/src/main/java/ghidra/framework/store/db/PackedDatabase.java