Chapter 11. Backing up an MBaaS
You can back up an MBaaS by following this procedure. After completing the procedure and storing the backup data safely, you can restore an MBaaS to the state at the time of backup.
11.1. Requirements
- A self-managed MBaaS installation on an OpenShift platform
-
A local installation of the
ocbinary -
The
ocbinary has a logged in user on the platform you wish to back up -
The
ocbinary has a logged in user with permission to run theoc get pccommand
11.2. Expected Storage Requirements
As most of the data being backed up is the data stored in the platform’s Cloud Apps, the amount of backup storage space required is proportional to the amount of data stored by the Cloud Apps.
Other factors that have an impact on how much storage is required for backups include:
- how often you backup
- what compression is used
- the length of time you store the backups
11.3. What Data is Backed Up
You must back up the following items to back up an MBaaS:
- MongoDB replica set data
- Nagios historical data
11.4. Backing up the MongoDB Data
Back up the MongoDB data using the mongodump command in combination with the oc exec command:
oc exec `oc get po --selector='deploymentconfig=mongodb-1' --template="{{(index .items 0).metadata.name}}"` bash -- -c '/opt/rh/rh-mongodb32/root/usr/bin/mongodump -u admin -p ${MONGODB_ADMIN_PASSWORD} --gzip --archive' > ./mbaas_mongodb.gz11.5. Backing up the Nagios Data
Back up the Nagios data by copying the files from the Nagios pod using the oc exec command:
oc exec <nagios-pod-name> bash -- -c 'tar -zcf - /var/log/nagios/' > nagios-backup.tar.gz
For example, if the <nagios-pod-name> is nagios-1:
oc exec nagios-1 bash -- -c 'tar -zcf - /var/log/nagios/' > nagios-backup.tar.gz
11.6. Backup Frequency
Red Hat recommends backing up at least once per day, but you might decide to back up critical data more frequently.
11.7. Example Backup Script
The example script below shows how you can back up an MBaaS from a backup server, assuming that the user on the backup server has permission to execute commands via the oc binary:
ts=$(date +%y-%m-%d-%H-%M-%S)
# Backup the Mongo services
project=mbaas
for pod in $(oc get pods -n $project | grep mongodb-[0-9]-[0-9]-[0-9a-zA-Z] | awk '{print $1}'); do
service=$(echo $pod | cut -f1,2 -d"-");
oc exec $pod bash -- -c '/opt/rh/rh-mongodb32/root/usr/bin/mongodump -u admin -p ${MONGODB_ADMIN_PASSWORD} --gzip --archive' > $project-$service-$ts.gz
done
# Backup the Nagios service
oc exec -n $project <nagios-pod-name> bash -- -c 'tar -zcf - /var/log/nagios/' > nagios-backup-$ts.tar.gz
Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.