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?

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.

  • What about any paid services? Are there any? – Sotiris Kaniras Feb 6 at 18:50
  • @SotirisKaniras Maybe you can use Azure backup to backup that disk every day. – Jason Ye Feb 8 at 2:05

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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