Skip to content

Instantly share code, notes, and snippets.

@joeangel
Created July 8, 2019 23:45
Show Gist options
  • Save joeangel/d0a12ff4253758a7f99c2a8b641b24ef to your computer and use it in GitHub Desktop.
Save joeangel/d0a12ff4253758a7f99c2a8b641b24ef to your computer and use it in GitHub Desktop.
#!/bin/bash
dbs="admin dbname1 dbname2"
user=admin
password=your-password
host=localhost:27017
i=0
for db in $dbs; do
echo [MongoDB] backup db: $db
mongodump -u ${user} -p ${password} --host ${host} --db ${db}
## use authenticationDatabase and ssl
#mongodump -u ${user} -p ${password} --host ${host} --db ${db} --authenticationDatabase=admin --ssl --sslAllowInvalidCertificates
((i++))
echo [MongoDB][] processed: ${i}
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment