Backup script for meteor mongodb
Backup script for meteor mongodb
This is a mix of several backup utilities collected from the community and packaged for easy deployment on EC2 (or other).
This script can easily download the contents of your meteor database and upload it to S3. It is designed to work well with hosting on meteor.com as well as private meteor deployments. And with a one small adjustments it is easy to make it work for generic mongo databases backups, not just meteor specific.
Set up a host to run the backup. In this example we show how to set up a micro EC2 host that'll run the nightly backups but of cousrse you may use any other hosting service or even your own laptop or PC.
my-perfect-backup
s3cmd
tool when it needs them. Create a role named MeteorMongoBackup. The Role Type should be Amazon EC2, next click on Custom Policy and insert the contents of the file MeteorMongoBackupRole.json
(replacing my-perfect-backup
with your own bucket name from step 0)MeteorMongoBackup
as the instance role. This will allow the host to seamlessly access your S3 bucket without needing to hardcode your AWS credentials on it.setup.sh
script. Note that this script contains many sections (some of them are optional) so my suggestion is that you read it and run each line manually.backup.sh
to update the SITE
URL and the COLLECTIONS
. The COLLECTIONS
is only needed if you want to crate cleartext (json) backups using the meteor-backup
tool. If you're only interested in binary backups (bson) using mongodump
then no need to specify the collections, they will all be backed up automatically, in binary format. json backups are useful for diffing or looking at just one collection's data, or grepping through them, but they also consume some more space.backup.sh
script by running /bin/bash backup.sh
crontab -e
and adding the contents of the crontab
file from this repositoryIf you're having troubles try following these steps:
backup.sh
outside of cron and check if it's successful. You should see DONE
at the end and no errors in betweem.* * * * *
(instead of 0 0 * * *
). Now tail syslog and wait for cron to run: tail -f /var/log/syslog
. Don't forget to update the cron string when you're done such that it won't run every minute forever...This simple setup is useful to backup meteor.com installation.
In case you'd like to backup other mongo installationas you might need just a subset of these, for example you will likely have the username/password provided, rather than having to run meteor mongo --url
and sed
to get the credentials.