Update old back-up and development environment in task.sh#172
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am approving your solution because it correctly implements the required backup and restore workflow: a full mysqldump of ShopDB into ShopDBReserve and a data-only dump (using --no-create-info) into ShopDBDevelopment, driven by DB_USER and DB_PASSWORD and runnable non-interactively for cron usage. All key functional requirements are met, and assuming the environment variables and MySQL server are configured, the Products table data will be present in both target databases with matching record counts.
One improvement to make your script more robust in real-world scheduling is to add a simple guard at the top that checks whether DB_USER and DB_PASSWORD are set and non-empty, and exits with a clear error message if they are missing (for example, if [ -z "$DB_USER" ] || [ -z "$DB_PASSWORD" ]; then echo "DB_USER/DB_PASSWORD must be set"; exit 1; fi). This will help avoid silent failures when the cron environment is misconfigured. You might also consider checking the exit codes of mysqldump and mysql to detect backup/restore errors and optionally logging them, but these are best-practice refinements rather than required changes for this task. Overall, your script meets the assignment’s functional standards; adding the suggested guards and error checks would make it even more reliable in production-like usage.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| #! /bin/bash | ||
|
|
||
| #Делаем бек-ап текущей базыданных. | Create back-up for current database. | ||
| mysqldump -u"$DB_USER" -p"$DB_PASSWORD" ShopDB --result-file=ShopDB_full_backup.sql |
There was a problem hiding this comment.
You rely on DB_USER and DB_PASSWORD being set but don’t check them; for a cron job this can easily fail silently if the environment is misconfigured, so consider adding a simple guard that exits with a clear error when these variables are empty.
No description provided.