Skip to content

Instantly share code, notes, and snippets.

@pablitoc
Created March 3, 2016 21:10
Show Gist options
  • Save pablitoc/53ba1bc9ebce66c1d8d9 to your computer and use it in GitHub Desktop.
Save pablitoc/53ba1bc9ebce66c1d8d9 to your computer and use it in GitHub Desktop.
mongo_backup.sh
#!/bin/sh
#ENV Variables
MONGO_HOST=
MONGO_PORT=
MONGO_DB_NAME=
MONGO_USERNAME=
MONGO_PASSWORD=
APP_PATH=
APP_NAME=
mongodump --host $MONGO_HOST --port $MONGO_PORT --db $MONGO_DB_NAME -u $MONGO_USERNAME -p $MONGO_PASSWORD --out '$APP_PATH'/dbbackups/backup_$(date +\%Y\%m\%d) && cd '$APP_PATH'/dbbackups && tar -zcf backup_$(date +\%Y\%m\%d).tar.gz backup_$(date +\%Y\%m\%d)/$APP_NAME
AWS S3 sync '$APP_PATH'/dbbackups/backup_$(date +\%Y\%m\%d).tar.gz s3://mongo_backups/
@pablitoc
Copy link
Author

pablitoc commented Mar 3, 2016

@pjkelly this is what I have so far. So I have been looking around and also reading Composes documentation Compose Backup Documentation and it looks like they are not flexible with their backup schedules. But they offer points as to how to create your own. So I went with it and was able to create this little script that can run as a cron job on a worker server. It is still a work in progress but at least you can see what is going on here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment