Exporting Documents to a Compressed File
- Last Updated: April 14, 2026
- 1 minute read
- MarkLogic Server
- Version 10.0
- Documentation
Use the mlcp export command to export documents in their original format as files in a compressed ZIP file on the native filesystem.
To export documents from a database as files:
-
Select the files to export. For details, see Filtering Document Exports.
-
To select documents in one or more collections, set
-collection_filterto a comma-separated list of collection URIs. -
To select documents in one or more database directories, set
-directory_filterto a comma-separated list of directory URIs. -
To select documents matching an XPath expression, use
-document_selector. To use namespace prefixes in the XPath expression, define the prefix binding using-path_namespace. -
To select documents matching a query, use
-query_filter, alone or in combination with one of the other filter options. False positives are possible; for details, see Understanding When Filters Are Accurate. -
To select all documents in the database, leave
-collection_filter,-directory_filter,-document_selector, and-query_filterunset.
-
-
Set
-output_file_pathto the destination directory on the native filesystem. This directory must not already exist. -
Set
-compresstotrue. -
To prettyprint exported XML when using local mode, set
-indentedto true.
For a full list of export options, see Export Command Line Options.
The zip files created by export have filenames of the form timestamp``-seqnum.zip.
The following example exports all the documents in the database to the directory /space/examples/export on the native filesystem.
# Windows users, see Modifying the Example Commands for Windows
$ mlcp.sh export -host localhost -port 8000 -username user \
-password password -mode local \
-output_file_path /space/examples/export -compress true
$ ls /space/examples/export 20120823135307-0700-000000-XML.zip