Skip to content

Update old back-up and development environment in task.sh#172

Open
1ntact wants to merge 1 commit into
mate-academy:mainfrom
1ntact:main
Open

Update old back-up and development environment in task.sh#172
1ntact wants to merge 1 commit into
mate-academy:mainfrom
1ntact:main

Conversation

@1ntact

@1ntact 1ntact commented Jun 30, 2026

Copy link
Copy Markdown

No description provided.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. Rate AI review example

Comment thread task.sh
#! /bin/bash

#Делаем бек-ап текущей базыданных. | Create back-up for current database.
mysqldump -u"$DB_USER" -p"$DB_PASSWORD" ShopDB --result-file=ShopDB_full_backup.sql

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants