mongosh
mongosh
manage mongodb using the command line
mongosh
mongosh is the tool to work with mongodb on the CLI
mongoshlist databases
show databasesshow collections
first open the database, then show the collections
use databaseName
show collectionsdatabase backup
backup all databases:
kubectl exec -it --tty mongodb-foo-bar -- sh -c '/usr/bin/mongodump --compressors=zstd --archive' | zstd - -o mongodb_$(date +%F).zstbackup just mydb:
kubectl exec -it --tty mongodb-foo-bar -- sh -c '/usr/bin/mongodump --compressors=zstd --db mydb --archive' | zstd - -o mydb_mongodb_$(date +%F).zst