Couchbase is NoSQL database system which allows us to store data in schemaless JSON format. When we are using the couchbase it is important to keep backup of the data so that in case of an accidental break down we can save the data.
Below is the process by which we can create backup of the couchbase instance on Ubuntu Linux.
Step 1 : create folder where you want to store the backup
Here I am creating folder “backup” on my desktop
kartheek@sails:~$ mkdir /home/kartheek/Desktop/backup
kartheek@sails:~$ sudo chmod -R a+rwx /home/kartheek/Desktop/backup/
Step 2 : Move to the bin folder of couchbase application. (Normally couchbase is installed at /opt/couchbase/)
kartheek@sails:~$ cd /opt/couchbase/bin
kartheek@sails:/opt/couchbase/bin$
Step 3 : Now there is script in couchbase called cbbackup.
kartheek@sails:/opt/couchbase/bin$ sh cbbackup http://localhost:8091 /home/kartheek/Desktop/backup/ -u Administrator -p sails123 [####################] 100.0% (7303/estimated 7303 msgs)
bucket: beer-sample, msgs transferred…
: total | last | per sec
byte : 2541549 | 2541549 | 940958.6
done
And you are done. The cbbackup script will store the couchbase data in the folder selected by us.
Now lets see how do we restore the saved backup to couchbase instance:
Step 1 : create Destination Bucket in the couchbase instance. (couchbase restore functionality will not create buckets automatically).
Go to the Cochbase web interface and type username and password
Now you appear the main screen and Click on Create New Data Bucket.
Now enter Bucket Name and Click on Create
Now you will get the following screen
Step 2 : Move to the bin folder of couchbase application. (Normally couchbase is installed at /opt/couchbase/)
kartheek@sails:/opt/couchbase/bin$ sh cbrestore /home/kartheek/Desktop/backup http://Administrator:sails123@localhost:8091 –bucket-source=beer-sample — bucket-destination=Sample
[####################] 100.0% (7303/estimated 7303 msgs)
bucket: beer-sample, msgs transferred…
: total | last | per sec
byte : 2541549 | 2541549 | 6880079.2
done
Note : Here the source bucket name has to be same which is used by the instance from which backup is created, whereas you can change the destination bucket name which is the bucket name that you have created in the instance where you are trying to restore the backup.
Note : Here the source bucket name has to be same which is used by the instance from which backup is created, whereas you can change the destination bucket name which is the bucket name that you have created in the instance where you are trying to restore the backup.