Skip to content

Instantly share code, notes, and snippets.

@AndreSlim
Created April 27, 2021 00:16
Show Gist options
  • Save AndreSlim/1f17558d60293bcacbb4be7cbb771d66 to your computer and use it in GitHub Desktop.
Save AndreSlim/1f17558d60293bcacbb4be7cbb771d66 to your computer and use it in GitHub Desktop.
Backup MongoDB
# Comandos para hacer un respaldo de la base de datos en MongoDB 4.2
# abrír una consola y ubicarse en los binarios de Mongo,
# en Windows C:\Program Files\MongoDB\Server\4.2\bin
# ===========================================
# - - - - - - - - Comandos - - - - - - - - -
# ===========================================
# CREAR
mongodump -h IP:PUERTO -d NOMBRE_BD -u USUARIO -p CONTRASEÑA --authenticationDatabase DB_DE_AUTENTICACION --out /PATH/DE/SALIDA/
# RESTAURAR
mongorestore -h IP:PUERTO -d NOMBRE_BD -u USUARIO -p CONTRASEÑA --authenticationDatabase DB_DE_AUTENTICACION /PATH/DE/RESPALDO/
# ===========================================
# - - - - - - - - Ejemplo - - - - - - - - - -
# ===========================================
# CREAR
mongodump -h 10.0.1.10:27020 -d PuntoVenta -u andres -p venta123 --authenticationDatabase admin --out C:/backup/bdd/
# RESTAURAR
mongorestore -h 10.0.1.10:27020 -d PuntoVenta-2 -u andres -p venta123 --authenticationDatabase admin C:/backup/bdd/PuntoVenta
# RESTAURAR LOCAL (Puede prescindir de credenciales)
mongorestore -h localhost:27017 -d PuntoVenta C:/backup/bdd/PuntoVenta
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment