Deployment Architecture


#1

Hi, I have recently deployed a new meteor app to Digital Ocean using MUP. I was wondering what others are doing about backing up their databases. I’m relatively new to sysadmin work and am not sure what the best way to backup my data would be, given the tight integration between MongoDB and Meteor. I’m not yet hosting my DB on a separate server, as it’s an application that will be seeing relatively low volume usage initially. Thanks.


#2

A cron job that does a mongodump each day would be a good start. But then you’d also want to automate moving the dumped data to another box for redundancy. There must be some good shell scripts out there for this sort of thing. Dev ops gurus … ?

Also, take a look at this topic. Using hosted db services makes backups trivially easy.

This one also has some thoughts on db hosting.


#3

You should definitely consider subsribing to https://mms.mongodb.com/ for both management and backups of your database. It is free up to your first 8 servers and backups are also free up to your first 1GB.

If you want to do that manually, something along the lines of:

Create a directory to keep your backups, and a backup script:

$ sudo mkdir /mongobackups
$ sudo nano /mongobackups/backup-script.sh

Paste this in and save (Ctl+X)

mongodump --db meteor --out /mongobackups/`date +%Y-%m-%d-%H-%M-%S`

Change your db name if you have named it something other than meteor

Make it an executable

$ sudo chmod +x /mongobackups/backup-script.sh

You can further secure it by changing its permissions.

Open up your crontab editor for root (you can do that for a specific backup user if you like)

$ sudo crontab -e

Then in the editor, add this

0  5    * * *   /mongobackups/backup-script.sh

Change the time if you like.

Now, this will run at 5am every day (on your server’s local timezone - cat /etc/timezone) to create a timestamped directory and dump your meteor database into it.

But again, I do suggest you consider MMS.

Edit as per @babrahams’s suggestion; I find rdiff-backup a very easy yet powerful backup solution:

$ sudo apt-get install rdiff-backup
$ rdiff-backup /mongobackups user@otherserver::/backupsofbackups 

Of course, one should ammend the first mongodump script with the rdiff backup command so that this runs after the dump.

PS: This is all assuming you are on an ubuntu(ish) system

PPS: Also, I know mup is great, so is cluster, as a great companion to it. But I use Phusion Passenger (nginx integration mode) to run multiple meteor apps on the same server, utilizing all the cores, firing up meteor instances depending on the load for each meteor app.


#4

This is great, @serkandurusoy . Thank you!


#5

Thanks for both your responses. I’ll definitely look over everything in the next few days. Much appreciated!


#6

Try this package https://atmospherejs.com/hitchcott/app-dump for In-app Backup and Restore for your Mongo Database.


#7

+1 for mms. Others have discussed other architectures here.


#8

+1 for MMS, you also get a ton of monitoring features for your replica set.


#9

I’m just getting around to this. I followed your directions to set up my own cron job to save backups, but I would also like to start using mms.mongodb.com to manage and monitor my databases. In the onboarding process, MMS is asking for a hostname and port. The mup docs don’t have much information on mongod hostnames or ports. However, I was able to pull the hostname from the db by running the hostname() command in the mongo shell, and tried the standard port…but no luck connecting to MMS. Did you have any issues setting this up? Thanks!


#10

I’ve actually never used mup before so I can’t tell. But If you’ve installed your mongodb instances using the mms client, you’ll be able to see all your mongodb hostnames and ports on your mms dashboard and then you’ll be able to update your mup configuration with that information.