Import and Export Data with Command Line Tools

  • Capella Operational
      +
      Use Couchbase command line tools to import and export large amounts of data.

      You can use the cbimport and cbexport command line tools included with Couchbase Server with a Couchbase Capella cluster. The command line tools are available as a separate package.

      Couchbase command line tools for Capella include cbimport and cbexport.

      • Use cbimport to import large datasets and multiple files at once, up to the maximum size of your Capella cluster.

      • Use cbexport to export data from your Capella cluster.

      Prerequisites

      The procedures on this page assume the following:

      Import Data

      1. Go to Connect  Import & Export Tools.

      2. Copy the command under cbimport.

      3. Replace username and password with the username and password of your cluster access credentials respectively.

      4. Update bucketname with the name of your bucket.

      5. Update dataset with the path to the dataset file.

      6. Set the cacert to point to the downloaded CA cert.

      You can also import from JSON. See the examples for more details.

      Export Data

      1. Copy the command under cbexport.

      2. Replace username and password with the username and password of your cluster access credentials respectively.

      3. Update the path to the location where you want to create your JSON file export.

      4. Update bucketname, scope, collection, and the collection_field with the name of your bucket, scope, and collection.

      5. Set the cacert to point to the downloaded CA cert.

      Import and Export with Command Line Tools Examples

      For production environments, use the secure --cacert <cert_file> option shown in the examples. For development environments, replace --cacert <cert_file> with --no-ssl-verify.

      For more information, see the Couchbase Server documentation for cbimport and cbexport.

      cbimport

      Import from CSV

      Use the cbimport csv command to import data into your Capella cluster from a CSV file:

      $ cbimport csv --cluster couchbases://cb.zjhxs-12ab3cd4e5.cloud.couchbase.com --username dbuser --password '******' --bucket mybucket1 --dataset file:///home/someuser/test_records.csv --generate-key '#UUID#' --infer-types --cacert /root/capella.pem --threads 4

      Import from JSON

      Use the cbimport json command to import data into your Capella cluster from a JSON file:

      $ cbimport json --cluster couchbases://cb.zjhxs-12ab3cd4e5.cloud.couchbase.com --username dbuser --password '******' --bucket mybucket1 --dataset file://./profile_docs.json --format lines --generate-key %profile_id% --cacert /root/capella.pem --threads 4

      In this example, the travel-sample-export.json was created with the cbexport example.

      $ cbimport json --cluster couchbases://cb.zjhxs-12ab3cd4e5.cloud.couchbase.com --username dbuser --password '******' --bucket mytravelsample --dataset file://./travel-sample-export.json --scope-collection-exp %myscopefield%.%mycollectionfield% --format lines --generate-key %doc_key% --ignore-fields doc_key,myscopefield,mycollectionfield --cacert /root/capella.pem

      cbexport

      Use the cbexport json command to export JSON documents from your Capella cluster.

      $ cbexport json --cluster couchbases://cb.zjhxs-12ab3cd4e5.cloud.couchbase.com --username dbuser --password '******' --bucket travel-sample --format lines --output  /home/someuser/travel-sample-export.json --scope-field myscopefield --collection-field mycollectionfield --include-key doc_key --cacert /root/capella.pem