Couchbase is a distributive clustered database which could be run on one or more than one nodes(server).
To take Couchbase database backup, you need to go on any one node of cluster(group of nodes on which our Couchbase is running). It doesn’t matter that the node on which you are logged in is data, query or index. Couchbase cluster manager takes care of it because cluster manager contains mapping among all cluster nodes.
Single dimensional cluster-
Multi dimensional(MDS) cluster-
Login on Couchbase Cluster –
In my case I’ll type-
ssh -i privateKey.pem user@anyNodeIP
Create Backup Folder –
Once you logged in on a node(server) you have to select(or you can create a new one) a directory where you are going to store this backup.
Suppose I am going to store this backup on backup directory.
sudo mkdir backup
Make sure that your /backup/ directory is writable otherwise you might face permission issue. You can make /backup/ directory writable by using chmod command-
sudo chmod 600 /backup/
Now to take backup you need to run cbbackup command. cbbackup is a couchbase library that exists in /opt/couchbase/bin
Take Backup with cbbackup –
Run following command to take backup which will be stored in /backup/ directory.
/opt/couchbase/bin/cbbackup http://localhost:8091 /backup/ -u username -p password
Once you type this command it will start to take backup of all buckets in the cluster.
Here the username and password are same that you use at the time of login on Couchbase UI. Please make sure that this user has sufficient access for taking backup.
If you have to take backup of particular couchbase bucket then you have to run following command-
/opt/couchbase/bin/cbbackup http://localhost:8091 /backup/ -u username -p password -b bucketName