cbrestore tool

cbrestore tool

The cbrestore tool restores data from a file to an entire cluster or to a single bucket in the cluster.

Description

Items that had been written to file on disk are restored to RAM.The cbbackup , cbrestore , and cbtransfer tools do not communicate with external IP addresses for server nodes outside of a cluster. Backup, restore, or transfer operations are performed on data from a node within a Couchbase cluster. They only communicate with nodes from a node list obtained within a cluster. This also means that if Couchbase Server is installed with a default IP address, an external hostname cannot be used to access it.

The tool is in the following locations:

Operating system Location
Linux /opt/couchbase/bin/cbrestore
Windows C:\Program Files\Couchbase\Server\bin\cbrestore
Mac OS X /Applications/Couchbase Server.app/Contents/Resources/couchbase-core/bin/cbrestore

CLI command and parameters

Basic syntax for this command:

cbrestore [options] [backup-dir] [destination]

Where:

  • [options]

    Command options for cbrestore are the same options for cbtransfer .

  • [backup-dir]

    The backup directory for the source data. This is in the directory created by cbbackup when performing the backup.

  • [destination]

    The destination bucket for the restored information. This is a bucket in an existing cluster. If restoring data to a single node in a cluster, provide the hostname and port of the node being restored to. If restoring an entire data bucket, provide the URL of one of the nodes within the cluster.

Important: Be sure to create the destination bucket before restoring the data.

The following are the command options:

Table 1. cbrestore options
Parameters Description
-h, --help Command line help.
-a, --add Used to not overwrite existing items in the destination. Use add instead of set.
-b BUCKET_SOURCE, --bucket-source=BUCKET_SOURCE Single named bucket from the backup directory to restore. If the backup directory only contains a signle bucket, then that bucket is automatically used.
-B BUCKET_DESTINATION, --bucket-destination=BUCKET_DESTINATION When --bucket-source is specified, overrides the destination bucket name. This allow you to restore to a different bucket. Defaults to the same as the bucket-source.
from-date=FROM_DATE Restore data from the date specified as yyyy-mm-dd. By default, all data from the very beginning is restored.
to-date=TO_DATE Restore data until the date specified as yyyy-mm-dd. By default, all data collected is restored.
-i ID, --id=ID Transfer only items that match a vbucket ID.
-k KEY, --key=KEY Transfer only items with keys that match a regexp.
-n, --dry-run No actual transfer. Just validate parameters, files, connectivity and configurations.
-u USERNAME, --username=USERNAME REST username for source cluster or server node.
-p PASSWORD, --password=PASSWORD REST password for cluster or server node.
-t THREADS, --threads=THREADS Number of concurrent workers threads performing the transfer.
-v, --verbose Verbose logging. More v's provide more verbosity. Max: -vvv.
-x EXTRA, --extra=EXTRA Provide extra, uncommon configuration parameters. Comma-separated key=val(key-val)* pairs.

The following are extra, specialized command options with the cbrestore -x parameter.

Table 2. cbrestore -x options
-x options Description
backoff_cap=10 Maximum backoff time during the rebalance period.
batch_max_bytes=400000 Transfer this # of bytes per batch.
batch_max_size=1000 Transfer this # of documents per batch.
cbb_max_mb=100000 Split backup file on destination cluster if it exceeds the MB.
conflict_resolve=1 By default, disable conflict resolution.
data_only=0 For value 1, transfer only data from a backup file or cluster.
design_doc_only=0 For value 1, transfer only design documents from a backup file or cluster. Default: 0.
max_retry=10 Max number of sequential retries if the transfer fails.
mcd_compatible=1 For value 0, display extended fields for stdout output.
nmv_retry=1 0 or 1, where 1 retries transfer after a NOT_MY_VBUCKET message. Default: 1.
recv_min_bytes=4096 Amount of bytes for every TCP/IP batch transferred.
rehash=0 For value 1, rehash the partition id's of each item. This is required when transferring data between clusters with different number of partitions, such as when transferring data from an Mac OS X server to a non-Mac OS X cluster.
report=5 Number batches transferred before updating progress bar in console.
report_full=2000 Number batches transferred before emitting progress information in console.
seqno=0 By default, start seqno from beginning.
try_xwm=1 Transfer documents with metadata. Default: 1. Value of 0 is only used when transferring from 1.8.x to 1.8.x.
uncompress=0 For value 1, restore data in uncompressed mode.

Syntax

The following is the basic syntax:

cbrestore [options] [backup-dir] [destination]

The following are syntax examples:


cbrestore /backups/backup-42 http://HOST:8091 \
  --bucket-source=default --from-date=2014-01-20 --to-date=2014-03-31
cbrestore /backups/backup-42 couchbase://HOST:8091 \
  --bucket-source=default
cbrestore /backups/backup-42 memcached://HOST:11211 \
  --bucket-source=sessions --bucket-destination=sessions2