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?