ELMA365 On-Premises / Backup external databases

Backup external databases

ELMA365 backup should be done for:

  • PostgreSQL;
  • MongoDB;
  • S3 Object Storage.

For a consistent state of the backup copy, disable the operation load. You can do it with the following commands:

kubectl scale deploy --replicas=0 --all -n default
kubectl -n default patch daemonset billing -p '{"spec": {"template": {"spec": {"nodeSelector": {"non-existing": "true"}}}}}'

Then wait for all the services to stop and run the backup.

After you have created a backup copy, run all the services using the following commands:

kubectl scale deploy --replicas=1 --all -n default
kubectl -n default patch daemonset billing --type json -p='[{"op": "remove", "path": "/spec/template/spec/nodeSelector/non-existing"}]'

Before recovering datab, you also have to stop all the application services completely and then recreate the PostgreSQL and MongoDB databses. To learn more see Install PostgreSQL and Install MongoDB.

Then recover the databases and restart the application services.

PostgreSQL Dump

To dump the PostgreSQL database, use the standard utility function:

pg_dump $postgresURL -C -c --if-exists -F directory -f $postgresDIR

MongoDB Dump

To dump the MongoDB database, use the standard utility function:

mongodump --uri $mongoURL --gzip --quiet --out $mongoDIR

S3 Dump

To copy the files, you can use any utility that connects to the S3 database, for example the mc:

mc mirror $source $destination

Restore PostgreSQL

To restore the PostgreSQL database, enter the following command:

pg_restore -d $postgresURL -j 1 -F directory $postgresDIR

Restore MongoDB

To restore the MongoDB database, enter the following command:

mongorestore --uri $mongoURL --dir $mongoDIR --drop --gzip --preserveUUID --excludeCollection=head.settings.view

Copy S3 files

To copy the files, use the command:

mc cp $backup $destination

 

 

Found a typo? Highlight the text, press ctrl + enter and notify us