Strategies for transferring mongoDB data between environments
This document describes the stragegies that can be used when cloning Sage X3 People environments or transferring elements from an environment to another. For relational database transfer associated to a Sage X3 People endpoint, we already have copy tools. But for administration data stored in mongoDB, these tools are not relevant, and we have to use other strategies. These strategies are described here.
This page has not the ambition to describe all the possibilities around mongoDB, but just to give some short information about the most frequent operation. A complete mongodb reference manual is available on mongoDB site.
In this first scenario, a complete staging environment has to be transferred on the customer environment
The right tools to use are the mongoDB tools mongodump
and mongorestore
.
These tools are available in bin subdirectory of mongodb installation path, and their syntax is rather simple:
The extraction of data uses the mongodump tool. The mongoDB database must of course be running to launch this command. The syntax (from a command line) is the following:
mongodump --db syracuse --out directory
--db syracuse
corresponds to the name of the mongoDB database, and directory
is the path of a directory that will be created to store the extracted data. in this directory, a subdirectory syracuse
(the name of the database) will be created.In this directory, for every collection (ie. administrative entity called <entity>
), two files will be created, called:
<entity>.metadata.json
<entity>.bson
The first file contains metadata (index definition), the second contains binary JSON data.
Every entity that has to be imported on another mongoDB instance will use data and metadata from these two files.
The integration of data uses the mongorestore tool. The mongoDB database must of course be running to launch this command. The syntax (from a command line) is the following:
mongorestore --db syracuse --drop directory
--drop
option is not mandatory, and allows deleting a collection before integrating it.All the collections present as json and bson files in the directory will be integrated.
It is important not not transfer the host
collection. This technical collection will be automatically created and their content include UUIDs that make it not transportable.
When this happens, the whole entities cannot be extracted and integrated, and you have to take care about the fact that some entities refer to other entities. Even if in the administrative interface, the references appears with their name, all the references are based on UUIDs. The collection can therefore not be transferred separately, but as
consistent groups of information.
Two tools are available to integrate consistent administration data: