Skip to main content

Using MarkLogic Content Pump (mlcp)

Exporting Documents to a Compressed File

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:

  1. Select the files to export. For details, see Filtering Document Exports.

    • To select documents in one or more collections, set -collection_filter to a comma separated list of collection URIs.

    • To select documents in one or more database directories, set -directory_filter to 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 postives 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_filter unset.

  2. Set -output_file_path to the destination directory on the native filesystem. This directory must not already exist.

  3. Set -compress to true.

  4. To prettyprint exported XML when using local mode, set -indented to 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