0

I have an application running on a Parse Server and another server where MongoDB runs. Both VMs are under Azure (Ubuntu VMs). A few weeks back, I wrote a db backup bash script which is run by crontab once a day, every day.

Here's the script:

#!/bin/bash

MONGO_DATABASE="db"
MONGO_HOST="127.0.0.1"
MONGO_PORT="portNo"
TIMESTAMP=`date +%d-%m-%Y--%H:%M:%S`
MONGODUMP_PATH="/usr/bin/mongodump"
BACKUPS_DIR="/datadrive/mongodb/backups/"
BACKUP_NAME="$TIMESTAMP"

# mongo admin --eval "printjson(db.fsyncLock())"
# $MONGODUMP_PATH -h $MONGO_HOST:$MONGO_PORT -d $MONGO_DATABASE
sudo $MONGODUMP_PATH -d $MONGO_DATABASE
# mongo admin --eval "printjson(db.fsyncUnlock())"

sudo mv dump $BACKUP_NAME
sudo tar -zcvf $BACKUPS_DIR/$BACKUP_NAME.tgz $BACKUP_NAME
sudo rm -rf $BACKUP_NAME
sudo find $BACKUPS_DIR/ -type f -mtime +0 -name '*.tgz' -delete

Ever since, I noticed a huge increment on the server's resources consumption, which costs twice as much than without the backup system!

My db's size is about 7GB and growing! What should I do in order to have a backup system that's CPU or otherwise efficient?

1

What should I do in order to have a backup system that's CPU or otherwise efficient?

Maybe you can deploy Mongodb replica sets, then use another VM to run backup crontab.

Also, you can run crontab in free time.

| improve this answer | |
  • What about any paid services? Are there any? – Sotiris Kaniras Feb 6 '18 at 18:50
  • @SotirisKaniras Maybe you can use Azure backup to backup that disk every day. – Jason Ye Feb 8 '18 at 2:05
  • Hi Jason, I would like utilize Azure backup service that should backup mongodb replicaset. Could you please highlight some points on that how to proceed. I am new to azure and would like to backup the mongodb via azure. – Sanjeev Apr 3 '19 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.