Flushing buckets

Flushing buckets

Buckets are flushed by enable the flush option then flushing.

Description

Flushing buckets involves:
  1. Enable the flush buckets option.
  2. Flush the bucket.

When you want to flush a data bucket, first enable this option and then actually issue the command to flush the data bucket. The --enable-flush option is either true or false. False is 0, meaning, do not enable flush (default). True is 1, meaning enable flush.

You can enable this option when you create the data bucket or edit bucket properties.

Important: After you explicitly enable data bucket flush, flush the data from the bucket. Flushing a bucket is data destructive. Client applications using this are advised to double check with the end user before sending such a request. You can control and limit the ability to flush individual buckets by setting the flushEnabled parameter on a bucket in Couchbase web console.
Warning: We do not advise that you enable this option if your data bucket is in a production environment.

CLI command and parameter

Flush can be enable when either creating or editing a bucket with the bucket-create and bucket-edit commands.

To enable bucket flush when creating a bucket, set the --enable-flush parameter to 1:

To flush the bucket, use couchbase-cli bucket-flush command.

Syntax

By default, the bucket-flush command confirms whether or not you truly want to flush the data bucket. You can optionally call this command with the --force option to flush data without confirmation.

Request syntax:


couchbase-cli bucket-flush -c [localhost]:8091 -u [admin] -p [password] 
    --bucket=[bucket-name] 
    --enable-flush=[0 | 1]
    [OPTIONS]
      

Example

Example request:


couchbase-cli bucket-flush -c 192.168.0.1:8091 -u Administrator -p password 
       --bucket=testBucket
       --enable-flush=1

Response

Example request response where you need to verify whether you want to flush the bucket. In this case, you need to specify either Yes or No.

Running this command will totally PURGE database data from disk. Do you really want to do it? (Yes/No)

Example request error response where the bucket that you want to flush is set up with XDCR replication:


ERROR: unable to bucket-flush; please check if the bucket exists or not; (503) Service Unavailable
{u'_': u'Cannot flush buckets with outgoing XDCR'}