Skip to content

Instantly share code, notes, and snippets.

@yvesh
Created April 5, 2020 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yvesh/02df5f84a2ce02d17bec2bd9ded17f92 to your computer and use it in GitHub Desktop.
Save yvesh/02df5f84a2ce02d17bec2bd9ded17f92 to your computer and use it in GitHub Desktop.
Docker MongoDB Backup script for cronjobs on Docker Host
#!/usr/bin/env bash
username=""
password=""
database=""
auth_database="admin"
target="/backup/mongo-$(date +%Y-%m-%d-%H).archive"
docker exec mongo_db_container sh -c 'exec mongodump --username $username --password $password --authenticationDatabase $auth_database -d $database --archive' > "$target"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment