Trove/backup-restore-single-instance-couchbase

Introduction
This article describes the design and process for backup and restore for Couchbase.

Blueprint
https://blueprints.launchpad.net/trove/+spec/backups-single-instance-couchbase

Future Follow up Blueprints

 * 1) Support incremental backup restore for Couchbase
 * 2) * Targeted for Couchbase 3.0
 * 3) * http://www.couchbase.com/issues/browse/MB-10176
 * 4) * https://blueprints.launchpad.net/trove/+spec/incremental-backup-restore-couchbase

Goals

 * 1) Implement backup and restore strategy for Couchbase

Dependencies

 * 1) Add support for 'trove root-enable' in Couchbase
 * 2) * https://review.openstack.org/#/c/81640
 * 3) Adds backup/restore support for mongodb
 * 4) * https://review.openstack.org/#/c/78339/ <-- requires some of the code changes introduced to support backup/restore for different datastores

Description

 * 1) Backup strategy
 * 2) * Backup directory is /tmp/backups
 * 3) * Save bucket metadata config (json file) as part of backup via:
 * 4) ** curl -u admin:password http://localhost:8091/pools/default/buckets
 * 5) ** This is needed on restore to create the destination buckets
 * 6) * Handles root enabled cause by also backing up /tmp/secret_key
 * 7) * Use cbbackup to do the backup
 * 8) ** Only backs up the raw data from Couchbase (membase) buckets. Skips memcached buckets because data is not persistent.
 * 9) ** http://docs.couchbase.com/couchbase-manual-2.5/cb-cli/#cbbackup-tool
 * 10) * Backup directory (/tmp/backups) will be zipped up, encrypted, and sent to Swift
 * 11) * If no buckets, backup will error out

Usage: cbrestore [options] backup_dir destination Restores a single couchbase bucket. Please first create the destination / bucket before restoring.
 * 1) Restore strategy
 * 2) * Get backup tarball from Swift, decrypt, and untar
 * 3) * If /tmp/backups/secret_key exists, set root password
 * 4) * Iterate through bucket metadata config (json file) and use Couchbase REST API to create each bucket
 * 5) ** http://docs.couchbase.com/couchbase-manual-2.5/cb-rest-api/#creating-and-editing-buckets
 * 6) * Wait until bucket finishes creating
 * 7) ** Follows same logic as couchbase-cli bucket-create --wait (because REST API doesn't have anything for "wait")
 * 8) *** https://github.com/couchbase/couchbase-cli/blob/master/buckets.py#L208-L252
 * 9) * Use cbrestore to do the restore