Skip to content

Commit

Permalink
Moved mgob documentation out of ssp chart
Browse files Browse the repository at this point in the history
  • Loading branch information
NikhilM98 committed Jul 10, 2020
1 parent 6412536 commit 15fed69
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 137 deletions.
66 changes: 2 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,72 +116,10 @@ helm install ssp .
Where `ssp` can be the name you want to give to this chart.

## Backup and Restore data using MGOB
You can implement backup and restore feature on the Sugarizer School Portal MongoDB replicaset by using MGOB.
[MGOB](https://github.com/stefanprodan/mgob/) is a MongoDB backup automation tool built with Go. It features like scheduled backups, local backups retention, upload to S3 Object Storage (Minio, AWS, Google Cloud, Azure) and upload to gcloud storage.

To setup MGOB to automate MongoDB backups on Google Kubernetes Engine, follow these step by step instructions:

Requirements:
- GKE cluster minimum version v1.8
- kubctl admin config

### Store Service Account key as a secret
First, you need to create a GCP service account key from the API & Services page. In case you already have one, then download the JSON file and rename it to `key.json`.

Store the JSON file as a secret:
```bash
kubectl create secret generic service-acc-secret --from-file=key.json
```

### MGOB Installation
Clone the MGOB repository:
```bash
git clone https://github.com/stefanprodan/mgob.git
cd mgob/chart
```
Edit the chart's `values.yaml` file.
- Set the appropriate `storageClass` for your provider.
- Update the `mgob-config` `configMap`. Add `sugarizer-database` backup plan.
Here is an example backup plan:
```bash
sugarizer-database.yml: |
target:
host: "mymongodb-mongodb-replicaset-0.mymongodb-mongodb-replicaset.default,mymongodb-mongodb-replicaset-1.mymongodb-mongodb-replicaset.default,mymongodb-mongodb-replicaset-2.mymongodb-mongodb-replicaset.default"
port: 27017
database: ""
scheduler:
cron: "0 0,6,12,18 */1 * *"
retention: 14
timeout: 60
```
- Add a reference to the secret. You can either insert your secret values as part of helm values or refer externally created secrets. In our case, we created a secret with a name `service-acc-secret`.
```bash
secret:
- name: service-acc-secret
```
An example YAML configuration is available as [mgob-gke.yaml](examples/mgob-gke.yaml).

### Backup to GCP Storage Bucket (Optional)
For long term backup storage, you could use a GCP Bucket since is a cheaper option than keeping all backups on disk.
You need to enable `storage.objects` acccess to the service account in order to allow objects creation in the bucket.
From the GCP web UI, navigate to Storage and create a regional bucket named `ssp-backup` (Or any other name if it's taken). Set the bucket and secret name in the backup-plan in the `values.yaml` file.
```bash
gcloud:
bucket: "ssp-backup"
keyFilePath: /secret/service-acc-secret/key.json
```

### Restoring data from backup
In order to restore data to the Sugarizer School Portal database, you need to open a shell in MGOB pod. The backups are available in `/storage/sugarizer-database/` directory inside the pod (where `sugarizer-database` was the name of our backup plan).

- In case of a database error in which you need to completely restore all the databases, you can run:
```bash
mongorestore --gzip --archive=/storage/sugarizer-database/sugarizer-database-xxxxxxxxxx.gz --host mymongodb-mongodb-replicaset-0.mymongodb-mongodb-replicaset.default:27017 --drop
```
- In case a school's DB is messed up and you need to restore that, you can run:
```bash
mongorestore --gzip --archive=/storage/sugarizer-database/sugarizer-database-xxxxxxxxxx.gz --nsInclude="db_name.*" --host mymongodb-mongodb-replicaset-0.mymongodb-mongodb-replicaset.default:27017 --drop
```
Where db_name is the name of the database to restore.
To setup MGOB to automate MongoDB backups on Google Kubernetes Engine, you can follow this [documentation](https://github.com/nikhilm98/sugarizer-school-portal#backup-and-restore-data-using-mgob).

## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Expand Down
73 changes: 0 additions & 73 deletions examples/mgob-gke.yaml

This file was deleted.

0 comments on commit 15fed69

Please sign in to comment.