This commit is contained in:
Rodolfo Berrios
2025-08-27 15:32:54 -04:00
parent 3624079d74
commit 996e881ce1

View File

@@ -292,16 +292,23 @@ database-backup:
database-restore:
@mkdir -p ./backup
@echo "🔍 Checking dump size..."
@ls -lh ./backup/${NAMESPACE}_chevereto.sql.gz
@echo "🔍 Preview of dump (first 20 lines after decompression):"
@gzip -dc ./backup/${NAMESPACE}_chevereto.sql.gz | head -n 20
@echo "🔍 Testing which client is available inside the container..."
@docker exec ${CONTAINER_BASENAME}_database sh -c 'command -v mysql || command -v mariadb || echo "no client found"'
@echo "🔍 Running restore..."
@gzip -dc ./backup/${NAMESPACE}_chevereto.sql.gz | \
docker exec -i ${CONTAINER_BASENAME}_database \
sh -c 'if command -v mysql >/dev/null 2>&1; then \
mysql -u root -ppassword chevereto; \
elif command -v mariadb >/dev/null 2>&1; then \
mariadb -u root -ppassword chevereto; \
else \
echo "Neither mysql nor mariadb client found in container" >&2; exit 1; \
fi'
@echo "🐬 Database restored from ./backup/${NAMESPACE}_chevereto.sql.gz"
sh -c 'set -x; \
if command -v mysql >/dev/null 2>&1; then \
mysql -u root -ppassword chevereto; \
elif command -v mariadb >/dev/null 2>&1; then \
mariadb -u root -ppassword chevereto; \
else \
echo "Neither mysql nor mariadb client found in container" >&2; exit 1; \
fi'
# nginx-proxy