cbexport json

Exports JSON data from Couchbase

SYNOPSIS

cbexport json [--cluster <url>] [--bucket <bucket_name>] [--format <data_format>]
              [--username <username>] [--password <password>] [--cacert <path>]
              [--no-ssl-verify] [--threads <num>] [--log-file <path>]
              [--include-key <key>] [--verbose]

DESCRIPTION

Exports JSON data from Couchbase. The cbexport-json command supports exporting JSON docments to a file with a document on each line or a file that contain a JSON list where each element is a document. The file format to export to can be specified with the --format flag. See the DATASET FORMATS section below for more details on the supported file formats.

OPTIONS

Below are a list of required and optional parameters for the cbexport-json command.

Required

-c,--cluster <url>

The hostname of a node in the cluster to export data from. See the HOST FORMATS section below for details about hostname specification formats.

-u,--username <username>

The username for cluster authentication. The user must have the appropriate privileges to read the bucket in which data will be exported from.

-p,--password <password>

The password for cluster authentication. The user must have the appropriate privileges to read from the bucket in which data will be exported from. Specifying this option without a value will allow the user to type a non-echoed password to stdin.

-b,--bucket <bucket_name>

The name of the bucket to export data from.

-f,--format <format>

The format of the dataset specified (lines or list). See the DATASET FORMATS section below for more details on the formats supported by cbexport.

-o,--output <path>

The path to the location of the file that JSON documnets from Couchbase should be exported to. This may be an absolute or relative path, but must point to a file. The file does not have to exist when the command is invoked.

Optional

--include-key <key>

Couchbase stores data as key value pairs where the value is a JSON document and the key is an identifier for retrieving that document. By default cbexport will only export the value portion of the document. If you wish to include the key in the exported document then this option should be specified. The value passed to this option should be the field name that the key is stored under. If the value passed already exists as a field in the document, it will be overridden with the key. If the JSON document is not an object it will be turn into one and the value added to a field named 'value'. If the key value passed is 'value' then the key will not be written. It will display a warning for any document it has converted into an object.

--no-ssl-verify

Skips the SSL verification phase. Specifying this flag will allow a connection using SSL encryption, but will not verify the identity of the server you connect to. You are vulnerable to a man-in-the-middle attack if you use this flag. Either this flag or the --cacert flag must be specified when using an SSL encrypted connection.

--cacert <cert_path>

Specifies a CA certificate that will be used to verify the identity of the server being connecting to. Either this flag or the --no-ssl-verify flag must be specified when using an SSL encrypted connection.

-t,--threads <num>

Specifies the number of concurrent clients to use when exporting data. Fewer clients means exports will take longer, but there will be less cluster resources used to complete the export. More clients means faster exports, but at the cost of more cluster resource usage. This parameter defaults to 1 if it is not specified and it is recommended that this parameter is not set to be higher than the number of CPUs on the machine where the export is taking place.

-l,--log-file <path>

Specifies a log file for writing debugging information about cbexport execution.

-v,--verbose

Specifies that logging should be sent to stdout. If this flag is specified along with the -l/--log-file option then the verbose option is ignored.

HOST FORMATS

When specifying a host for the couchbase-cli command the following formats are expected:

  • couchbase://<addr>

  • <addr>:<port>

  • http://<addr>:<port>

It is recommended to use the couchbase://<addr> format for standard installations. The other two formats allow an option to take a port number which is needed for non-default installations where the admin port has been set up on a port other that 8091.

DATASET FORMATS

The cbexport command supports the formats listed below.

LINES

The lines format specifies a file that contains one JSON document on every line in the file. This format is specified by setting the --format option to "lines". Below is an example of a file in lines format.

{"key": "mykey1", "value": "myvalue1"}
{"key": "mykey2", "value": "myvalue2"}
{"key": "mykey3", "value": "myvalue3"}
{"key": "mykey4", "value": "myvalue4"}

LIST

The list format specifies a file which contains a JSON list where each element in the list is a JSON document. The file may only contain a single list, but the list may be specified over multiple lines. This format is specified by setting the --format option to "list". Below is an example of a file in list format.

[
  {
    "key": "mykey1",
    "value": "myvalue1"
  },
  {"key": "mykey2", "value": "myvalue2"},
  {"key": "mykey3", "value": "myvalue3"},
  {"key": "mykey4", "value": "myvalue4"}
]

EXAMPLES

To export data to /data/lines.json using the lines format and running with 4 threads the following command can be run.

$ cbexport json -c couchbase://127.0.0.1 -u Administrator -p password \
 -b default -0 /data/lines.json -f lines -t 4

To export data from /data/list.json using the list format the following command can be run.

$ cbimport json -c couchbase://127.0.0.1 -u Administrator -p password \
 -b default -o /data/list.json -f list

ENVIRONMENT AND CONFIGURATION VARIABLES

(None)

SEE ALSO

CBEXPORT

Part of the cbexport suite