Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Backing Up Contrail Databases Using JSON Format

This document shows how to backup Contrail databases (Cassandra and Zookeeper) using a JSON format. Instructions are given for both non-containerized and containerized versions of Contrail, starting with Contrail 4.0.

Preliminary Cautions

CAUTION:

Because the state of the Contrail database is associated with other system databases, such as OpenStack databases, database backups must be consistent across all systems and database changes associated with northbound APIs must be stopped on all systems before performing any backup operation. For example, you might block the external VIP for northbound APIs at the load balancer level, such as HAproxy.

Simple Backup Using JSON Format

Perform a simple backup (database dump). Working from a controller node, use db_json_exim.py, located at /usr/lib/python2.7/dist-packages/cfgm_common.

Note:

The controller node for non-containerized Contrail is a virtual machine (VM).

The controller node for containerized Contrail is a controller container.

cd /usr/lib/python2.7/dist-packages/cfgm_common

python db_json_exim.py --export-to db-dump.json

  • To see a cleaner version of the dump.

    cat db-dump.json | python -m json.tool | less

  • To omit keyspace in the dump, for example, to share with Juniper.

    python db_json_exim.py --export-to db-dump.json --omit-keyspace dm_keyspace

Restore Simple Database Backup

Use the following steps to restore a system from a simple backup.

  1. Stop supervisor-config on all controllers, if present, or ensure it is already stopped.

    service supervisor-config stop

  2. Stop Cassandra on all config-db controllers or ensure it is already stopped.

    service cassandra stop

  3. Stop Zookeeper on all controllers or ensure it is already stopped.

    service zookeeper stop

  4. Stop Kafka on all controllers. Be sure to check analytics controllers.

    service kafka stop

  5. Stop contrail-hamon on all controllers, if it is running on controllers.

    service contrail-hamon stop

  6. Backup the Zookeeper data directory on all controllers.

    cd /var/lib/zookeeper/

    cp -R version-2/ version-2-save

  7. Backup the Cassandra data directory on all controllers.

    cd /var/lib/

    cp -R cassandra cassandra-save

  8. Wipe out the Zookeeper data directory contents on all controllers.

    rm -rf /var/lib/zookeeper/version-2/*

  9. Wipe out the Cassandra data directory contents on all controllers.

    rm -rf /var/lib/cassandra/*

  10. Start Zookeeper on all controllers.

    service zookeeper start

  11. Start Cassandra on all controllers.

    service cassandra start

  12. Run python db_json_exim.py --import-from db-dump.json on any one controller.

    cd /usr/lib/python2.7/dist-packages/cfgm_common

    python db_json_exim.py --import-from db-dump.json

  13. Start supervisor-config on all controllers (if present).

    service supervisor-config start

  14. Start Kafka on all controllers (check in analytics controllers).

    service kafka start

  15. Start contrail-hamonon all controllers, if previously stopped.

    service contrail-hamon start

Example Backup and Restore With JSON

This section provides an example of a simple database backup and restore of a system that has three controllers with config-db and separate IPs with the following host IDs:

  • 5b5s42

  • 5b5s43

  • 5b5s44

Example: Perform Simple Backup

Example: Perform Restore

  1. Stop supervisor-config on all controllers, if present.

  2. Stop Cassandra on all controllers.

  3. Stop Zookeeper on all controllers.

  4. Stop Kafka on all controllers.

  5. Stop contrail-hamon on all controllers, if present.

  6. Backup the Zookeeper data directory on all controllers.

  7. Backup the Cassandra data directory on all controllers.

  8. Wipe out the Zookeeper data directory contents on all controllers.

  9. Wipe out the Cassandra data directory contents on all controllers.

  10. Start Zookeeper on all controllers.

  11. Start Cassandra on all controllers.

  12. Run python db_json_exim.py --import-from db-dump.json on any one controller.

  13. Start supervisor-config on all controllers, if present.

  14. Start Kafka on all controllers.

  15. Start contrail-hamonon all controllers, if present.