Solution 1.0.0#155
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
The script has critical bugs that prevent it from functioning. On lines 3 and 7, variables are written as literal strings "DB_USER" and "DB_PASSWORD" instead of $DB_USER and $DB_PASSWORD - this causes MySQL to attempt authentication with the literal username "DB_USER", which will always fail. Additionally, the backup/restore logic is incorrect: piping mysqldump directly to mysql doesn't work - you need to write to a file first with mysqldump > file.sql, then restore with mysql < file.sql. On the second operation, you're using mysqldump to dump FROM ShopDBDevelopment instead of using mysql to restore TO it. These issues mean the script cannot meet the task requirements for full backup to ShopDBReserve or data-only restore to ShopDBDevelopment.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
| @@ -1 +1,5 @@ | |||
| #! /bin/bash | |||
|
|
|||
| mysqldump -u"DB_USER" -p"DB_PASSWORD" ShopDB --no-create-db --result-file=ShopDB.backup.sql | mysql -u"DB_USER" -p"DB_PASSWORD" ShopDBReserve > ShopDB.backup.sql | |||
There was a problem hiding this comment.
Variables are not expanded - should use $DB_USER and $DB_PASSWORD, not literal strings "DB_USER" and "DB_PASSWORD". Without the $ prefix, bash treats these as literal strings rather than environment variables.
| @@ -1 +1,5 @@ | |||
| #! /bin/bash | |||
|
|
|||
| mysqldump -u"DB_USER" -p"DB_PASSWORD" ShopDB --no-create-db --result-file=ShopDB.backup.sql | mysql -u"DB_USER" -p"DB_PASSWORD" ShopDBReserve > ShopDB.backup.sql | |||
There was a problem hiding this comment.
The restore logic is incorrect. Piping mysqldump to mysql won't properly restore data. The correct approach is: mysqldump to create a file, then mysql to restore from that file. Also missing database name 'ShopDB' in mysqldump command, and 'ShopDBReserve' should be the mysql database argument.
|
|
||
| mysqldump -u"DB_USER" -p"DB_PASSWORD" ShopDB --no-create-db --result-file=ShopDB.backup.sql | mysql -u"DB_USER" -p"DB_PASSWORD" ShopDBReserve > ShopDB.backup.sql | ||
|
|
||
| mysqldump -u"DB_USER" -p"DB_PASSWORD" --no-create-info --result-file=ShopDBNoInfo.backup.sql | mysqldump -u"DB_USER" -p"DB_PASSWORD" ShopDBDevelopment > ShopDBNoInfo.backup.sql No newline at end of file |
There was a problem hiding this comment.
Variables are not expanded - should use $DB_USER and $DB_PASSWORD. Same issue as line 3.
|
|
||
| mysqldump -u"DB_USER" -p"DB_PASSWORD" ShopDB --no-create-db --result-file=ShopDB.backup.sql | mysql -u"DB_USER" -p"DB_PASSWORD" ShopDBReserve > ShopDB.backup.sql | ||
|
|
||
| mysqldump -u"DB_USER" -p"DB_PASSWORD" --no-create-info --result-file=ShopDBNoInfo.backup.sql | mysqldump -u"DB_USER" -p"DB_PASSWORD" ShopDBDevelopment > ShopDBNoInfo.backup.sql No newline at end of file |
There was a problem hiding this comment.
The restore logic is incorrect. Piping mysqldump output to another mysqldump makes no sense. Also missing the source database 'ShopDB' in the mysqldump command. To restore data-only backup to ShopDBDevelopment, you need: mysqldump for backup, then mysql to restore to ShopDBDevelopment.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your solution is approved. The script now correctly implements all task requirements: it properly reads credentials from $DB_USER and $DB_PASSWORD environment variables, creates a full backup of ShopDB to ShopDBReserve using intermediate .sql files, and creates a data-only backup to ShopDBDevelopment using the --no-create-info flag. The previous critical bugs with literal string variables and incorrect backup/restore logic have been successfully resolved. Great work on fixing those issues and ensuring the script is ready for cron job execution.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.