Skip to content
Pipat Saengow edited this page Nov 2, 2022 · 1 revision

Backing Up

CU Get Reg utilized databases to store user's data and logs. There are two important database in CU Get Reg:

  • Mongo
    • Stores user's login and course selections.
    • Stores scrapped course and provides course search.
  • ElasticSearch
    • Stores user behaviors for analysis.

It is important that these data be backed up periodically. This is currently done manually by me running commands on the server.

This document will shows how to performs back-up

Prerequisite

You must have SSH access to CU Get Reg's Server. So that you can do docker exec. To do that, you need to:

  1. Connect Reg CU's Fortinet VPN
  2. SSH to cugetreg host via the internal IP

Backing up Mongo

Run following commands to export cugetreg mongo db to an archive file. and copy it with SCP to somewhere safe.

docker exec cugetreg-mongo mongodump --archive=2022-11-02.mongo --db=cugetreg
docker cp cugetreg-mongo:2022-11-02.mongo .
docker exec cugetreg-mongo rm 2022-11-02.mongo
scp cugetreg:2022-11-02.mongo backup

Backing up ElasticSearch

I have already register a snapshot repository with the ES. You just need to docker exec inside and trigger snapshot creation.

docker exec -it cugetreg-elasticsearch bash
curl -XPUT localhost:9200/_snapshot/myrepo/2022-11-02
curl localhost:9200/_snapshot/myrepo/2022-11-02

See if the last command said that snapshot is created.

Once done, package it up using tar and put it to somewhere safe:

tar cvzf elastic-2022-11-02.tar.gz /home/cugetreg/volumes/elastic-tmp/
scp cugetreg:elastic-2022-11-02.tar.gz .