Skip to content

Commit

Permalink
⚡️ respaldos
Browse files Browse the repository at this point in the history
  • Loading branch information
1cgonza committed Nov 1, 2024
1 parent 35b4f08 commit 3a2838c
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ datos/*
cache
api
www
respaldo/*
!respaldo/README.md

# Logs
logs
Expand All @@ -32,3 +34,4 @@ dist-ssr
*.njsproj
*.sln
*.sw?

15 changes: 15 additions & 0 deletions crearRespaldo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# crearRespaldo.sh

# Install Environment file
source .env

# Backup MongoDB
/usr/bin/docker exec colev-api-bd mongodump \
--authenticationDatabase admin \
--archive \
--username $BD_USUARIO \
--password $BD_CLAVE \
--db colev \
--archive \
> ./respaldo/respaldo_datos_colev.dump
3 changes: 1 addition & 2 deletions docker-compose-desarrollo.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.8'

services:
bd:
container_name: colev-api-bd-desarrollo
Expand Down Expand Up @@ -42,6 +40,7 @@ services:
cache:
condition: service_started
environment:
ME_CONFIG_MONGODB_PORT: ${BD_PUERTO}
ME_CONFIG_MONGODB_ADMINUSERNAME: ${BD_USUARIO}
ME_CONFIG_MONGODB_ADMINPASSWORD: ${BD_CLAVE}
ME_CONFIG_MONGODB_SERVER: bd
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.8'

services:
bd:
container_name: colev-api-bd
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@
"ignore": [
"datos/*"
]
}
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
1 change: 1 addition & 0 deletions respaldo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Carpeta para guardar los respaldos (.dump de Mongo)
16 changes: 16 additions & 0 deletions restaurarRespaldo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# restaurarRespaldo.sh

# Cargar variables de entorno
source .env

# Ruta del archivo de respaldo
RUTA="./respaldo/respaldo_datos_colev.dump"

# Restaurar MongoDB
/usr/bin/docker exec -i colev-api-bd mongorestore \
--authenticationDatabase admin \
--archive= $RUTA \
--username $BD_USUARIO \
--password $BD_CLAVE \
--db colev

0 comments on commit 3a2838c

Please sign in to comment.