March 23, 2025
+ 12
Use Couchbase command line tools to manage ad hoc backups.

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

Use cbbackupmgr to back up and restore data across multiple Capella clusters, either in development or production environments. For more information about cbbackupmgr, see cbbackupmgr in the Couchbase Server documentation.

For data migration between Couchbase clusters, Cross Data Center Replication (XDCR) is generally recommended. When XDCR cannot be used, the recommended method is to use cbbackupmgr backup and cbbackupmgr restore. Using cbexport and cbimport to migrate data from a Couchbase bucket that holds Sync Gateway data can cause the data to be corrupted.

Prerequisites

All procedures and examples on this page assume the following:

Backup and Restore Examples

For full examples, see cbbackupmgr in the Couchbase Server documentation.

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.

Use the cbbackupmgr backup and cbbackupmgr restore commands to back up and restore your Capella cluster.

Use the --capella option to disable the backup or restore of data that cannot be read or written by your Capella cluster access credentials.

console
$ cbbackupmgr config --archive /home/couchbase/backups --repo capella_db1 --capella
Back up all buckets
console
$ cbbackupmgr backup --archive /home/couchbase/backups --repo capella_db1 --cluster couchbases://cb.zjhxs-12ab3cd4e5.cloud.couchbase.com --username dbuser --password '******' --cacert /root/capella.pem --full-backup --threads 4

To only restore mybucket1 data, and restore it to bucket newbucket1:

console
$ cbbackupmgr restore --archive /home/couchbase/backups --repo capella_db1 --cluster couchbases://cb.zjhxs-12ab3cd4e5.cloud.couchbase.com --username dbuser --password '******' --cacert /root/capella.pem --include-data mybucket1 --map-data mybucket1=newbucket1 --threads 4

Back up a Free Tier Capella Operational Cluster and Restore to a Paid Operational Cluster

This example uses cbbackupmgr CLI to migrate data from a free tier operational cluster to a paid operational cluster.

Back Up a Free Tier Operational Cluster

To configure the cbbackupmgr archive repository to hold the backup:

console
$ cbbackupmgr config --archive /home/couchbase/backups --repo capella_free --capella

To back up a free tier Capella operational cluster:

console
$ cbbackupmgr backup --archive /home/couchbase/backups --repo capella_free -c couchbases://cb.ubibrahu6aizk5rm.cloud.couchbase.com -u freeuser -p '******' --cacert /root/capella.pem --full-backup --threads 2

Restore to a Paid Provisioned Cluster

Make sure you have created the Couchbase buckets to restore to your paid provisioned cluster. Cluster access credentials do not have privileges to create a bucket, so you cannot use the cbbackupgmr restore option --auto-create-buckets when restoring to a Capella cluster.

To restore to a paid provisioned cluster:

console
$ cbbackupmgr restore --archive /home/couchbase/backups --repo capella_free -c couchbases://cb.20xa2skdftoygjxe.cloud.couchbase.com -u dbuser -p '******' --cacert /root/capella.pem --capella

The --purge option cleans up restore progress information from the previous restore attempt. Add the --purge option to the restore command to rerun the restore if you get an error at the start of the restore.

See Allowed IPs Tips and Restore Tips for more restoring tips.

Build Indexes

Index definitions are restored but not built.

To build the indexes in your cluster:

  1. Open your cluster in the Capella UI.

  2. Go to Data Tools  Indexes.

  3. Build the indexes that are in a "Created" state.

Backup a Self-Managed Cluster and Restore to a Capella Provisioned Cluster

This example uses cbbackupmgr CLI to migrate data from a self-managed cluster to a provisioned cluster.

A self-managed cluster can be either an Enterprise or Community Edition cluster. If you’re using the Community Edition of Couchbase Server, you need to use the cbbackupmgr CLI from the command line tools package to restore to the Capella provisioned cluster. You can also use the cbbackupmgr CLI from the command line tools package for backup.

Backup a Self-Managed Cluster

You can backup a self-managed cluster or use an existing backup. The example below is when you do not have an existing backup.

To configure the cbbackupmgr archive repository to hold the backup:

console
$ cbbackupmgr config --archive /home/couchbase/backups --repo repo_mydb

To backup a self-managed cluster:

console
$ cbbackupmgr backup --archive /home/couchbase/backups --repo repo_mydb -c localhost -u Administrator -p '******'

Restore to a Paid Provisioned Cluster

If your self-managed cluster is using the Community Edition Couchbase Server, you must use the cbbackupmgr CLI from the command line tools package to restore to the Capella provisioned cluster.

Ensure you have created the Couchbase buckets to restore to your paid provisioned cluster. Capella cluster access credentials do not have privileges to create a bucket, so you cannot use the cbbackupgmr restore option --auto-create-buckets when restoring to a Capella cluster.

To restore to a paid provisioned cluster:

console
$ cbbackupmgr restore --archive /home/couchbase/backups --repo repo_mydb -c couchbases://cb.eqwqztkw5e5kf6l.cloud.couchbase.com --cacert /root/capella.pem -u dbuser -p '******' --disable-analytics --disable-cluster-analytics --disable-bucket-query --disable-cluster-query --disable-views
While this example works with all cbbackupmgr versions, when using cbbackupmgr version 7.6 or later, you can use --capella instead of the --disable-analytics --disable-cluster-analytics, --disable-bucket-query, --disable-cluster-query, and --disable-views options.

The --purge option cleans up restore progress information from the previous restore attempt. Add the --purge option to the restore command to rerun the restore if you get an error at the start of the restore.

See Allowed IPs Tips and Restore Tips for more restoring tips.

Build Indexes

Index definitions are restored but not built.

To build the indexes in your cluster:

  1. Open your cluster in the Capella UI.

  2. Go to Data Tools  Indexes.

  3. Build the indexes that are in a "Created" state.

Allowed IPs Tips

If you’re running cbbackupmgr CLI from a VPC-peered environment, the Capella connection string may resolve to a private IP address in your environment. In this situation, you do not need to add the IP address of the machine you’re running cbbackupmgr on to the Capella cluster’s list of allowed IPs.

If you have a private endpoint set up in your Capella provisioned cluster, and you’re using the Capella private endpoint DNS name to connect, you do not need to add the IP address of the machine you’re running cbbackupmgr on to the list of allowed IPs.

Example private endpoint DNS name connection:
couchbases://private-endpoint.iml6stsfy4njxkx0.cloud.couchbase.com

Restore Tips

The --purge option cleans up restore progress information from the previous restore attempt.

Add the --purge option to the restore command to rerun the restore if you get an error at the start of the restore because you omitted to do the following:

  • Create the buckets in the provisioned cluster.

  • Create the cluster access credential.

  • Specify the certificate option.

If the restore process is running, and gets interrupted due to a temporary network issue, try restoring again from where you left off using the --resume option.

Other specific restore options are shown in the following table:

Option Description Example

--map-data

Restore to different bucket names.

--map-data oldbucket1=newbucket1,oldbucket2=newbucket2

--include-data

Restore only specific buckets, scopes, and collections.

--include-data bucket1.scope1,bucket2.scope2.collection3

--exclude-data

Exclude specific buckets, scopes, and collections from the restore.

--exclude-data bucket2.scope1

--threads

Specify the number of concurrent clients to use during backup or restore. The default is 1. More clients means more resource usage. The value should not exceed the number of CPUs on the machine running cbbackupmgr.

--threads 4

There are other cbbackupmgr restore options. For example, if the backup you’re restoring also includes Search indexes, you may want to restore the data first, followed by restoring the Search indexes. If you restore the data and the Search indexes concurrently, the restore starts by creating the Search indexes, followed by the restore data, which puts a very high load on the Search nodes.

GSI indexes do not have the same issue as the Search indexes because they’re restored deferred. The index definitions are restored, but the indexes are not built. You must build the GSI indexes manually after the restore completes.

To disable restoring Search indexes, add the following disable options to your cbbackupmgr restore command:
--disable-ft-indexes and --disable-ft-alias

Example:

console
$ cbbackupmgr restore --archive /home/couchbase/backups --repo repo_mydb -c couchbases://cb.eqwqztkw5e5kf6l.cloud.couchbase.com --cacert /root/capella.pem -u dbuser -p '******' --disable-analytics --disable-cluster-analytics --disable-bucket-query --disable-cluster-query --disable-views --disable-ft-indexes --disable-ft-alias

After restoring your data, GSI indexes, and eventing functions, to restore the Search indexes by adding the disable options for data, GSI indexes, and eventing, run another cbbackupmgr restore command:
--disable-data --disable-gsi-indexes --disable-eventing

Example:

console
$ cbbackupmgr restore --archive /home/couchbase/backups --repo repo_mydb -c couchbases://cb.eqwqztkw5e5kf6l.cloud.couchbase.com --cacert /root/capella.pem -u dbuser -p '******' --disable-analytics --disable-cluster-analytics --disable-bucket-query --disable-cluster-query --disable-views --disable-data --disable-gsi-indexes --disable-eventing