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?

Sotiris Kaniras
  • 198
  • 2
  • 10
  • incremental backups can be great, but for mongodb the issue is tricky. there isnt really a convenient way to do it without paying for expensive services (mongodb cloud) or writing your own scripts (https://tech.willhaben.at/mongodb-incremental-backups-dff4c8f54d58) – Qiong Wu Feb 05 '18 at 08:49

1 Answers1

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.

Jason Ye
  • 2,399
  • 1
  • 8
  • 10
  • What about any paid services? Are there any? – Sotiris Kaniras Feb 06 '18 at 18:50
  • @SotirisKaniras Maybe you can use Azure backup to backup that disk every day. – Jason Ye Feb 08 '18 at 02: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 03 '19 at 08:18