Couchbase Backup and Restore with cbbackupmgr Tool

By | June 27, 2019
Couchbase Backup and Restore with cbbackupmgr Tool

In my last two tutorial of Couchbase backup and restore I have explained how to take backup and restore it on Couchbase using cbbbackup and cbrestore libraries(which exist in /opt/couchbase/bin/ for linux). But there is also another tool cbbackupmgr (exists in same directory /opt/couhbase/bin/) which backs up and restores bucket data, views creation scripts, index creation scripts, bucket configurations, and so on. So here I am going to tell you how to take couchbase backup and restore with cbbackupmgr tool step by step –

Step #1: Go on the directory where you want to store backup folder.

system@del1-lhp-n02552:~$ cd anyDir/

Make sure that you are going to type all following commands from the same directory.

Step #2: Now set the environment variables-

system@del1-lhp-n02552:~$ export Backup_Folder_NAME=<backupFolder> 
system@del1-lhp-n02552:~$ export CB_USER_NAME=<user_name> 
system@del1-lhp-n02552:~$ export CB_PASSWORD=<password>

Step #3: Now create the backup config. It will just create a folder where your backup will be stored.

system@del1-lhp-n02552:~$ /opt/couchbase/bin/cbbackupmgr config -a $(pwd)/$Backup_Folder_NAME -r $Backup_Folder_NAME

Step #5: You can verify the backup config is created successfully using the following command. Note, we have to use the absolute path here.

system@del1-lhp-n02552:~$ /opt/couchbase/bin/cbbackupmgr list -a $(pwd)/$Backup_Folder_NAME
Size      Items          Name
  0B        -              /
  0B        -              + backupFolder

Step#6: Now to take backup type command –

system@del1-lhp-n02552:~$ /opt/couchbase/bin/cbbackupmgr backup -a $(pwd)/$Backup_Folder_NAME -r $Backup_Folder_NAME -c couchbase://localhost -u CB_USER_NAME -p CB_PASSWORD

Backing up to 2019-06-27T13_56_15.021254784+05_30
 Copied all data in 12.01s (Avg. 7.00KB/Sec)                                                                                                                                              0 items / 84.00KB
 bucket1                   [========================================================================================================================================================================] 100.00%
 bucket2                   [========================================================================================================================================================================] 100.00%
 bucket3                   [========================================================================================================================================================================] 100.00%
 Backup successfully completed

Again you can verify the backup is taken successfully using the following command.

system@del1-lhp-n02552:~$ /opt/couchbase/bin/cbbackupmgr list -a $(pwd)/$Backup_Folder_NAME

Size      Items          Name
  150.11MB  -              /
  150.11MB  -              + backupFolder
  150.11MB  -                  + 2019-06-27T11_08_59.748870162+05_30
  50.04MB   -                      + bucket1
  408B      0                          bucket-config.json
  50.04MB   3                          + data
  50.04MB   3                              shard_0.fdb
  2B        0                          full-text.json
  1.57KB    1                          gsi.json
  2B        0                          views.json
  50.03MB   -                      + bucket2
  408B      0                          bucket-config.json
  50.03MB   1                          + data
  50.03MB   1                              shard_0.fdb
  2B        0                          full-text.json
  1.57KB    1                          gsi.json
  2B        0                          views.json
  50.04MB   -                      + bucket3
  408B      0                          bucket-config.json
  50.04MB   2                          + data
  50.04MB   2                              shard_0.fdb
  2B        0                          full-text.json
  1.57KB    1                          gsi.json
  2B        0                          views.json

Step #7: You can restore backup data with following command –

system@del1-lhp-n02552:~$ /opt/couchbase/bin/cbbackupmgr restore -a $(pwd)/$Backup_Folder_NAME -r $Backup_Folder_NAME -c couchbase://localhost -u CB_USER_NAME -p CB_PASSWORD

Restoring backup 2019-06-27T13_56_15.021254784+05_30 
 Copied all data in 2s (Avg. 10kB/Sec)                                                                                                                                                           0 items / 0B
 bucket1                   [========================================================================================================================================================================] 100.00%
 bucket2                   [========================================================================================================================================================================] 100.00%
 bucket3                   [========================================================================================================================================================================] 100.00%
 Restore completed successfully

So this was all about Couchbase Backup and Restore with cbbackupmgr Tool. In case of any doubt or query please comment below, I’ll give reply ASAP.

Leave a Reply

Your email address will not be published. Required fields are marked *