Skip to content

Solution 1.0.0#155

Open
Aisengrim wants to merge 4 commits into
mate-academy:mainfrom
Aisengrim:main
Open

Solution 1.0.0#155
Aisengrim wants to merge 4 commits into
mate-academy:mainfrom
Aisengrim:main

Conversation

@Aisengrim

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

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. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread task.sh Outdated
@@ -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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread task.sh Outdated
@@ -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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread task.sh Outdated

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variables are not expanded - should use $DB_USER and $DB_PASSWORD. Same issue as line 3.

Comment thread task.sh Outdated

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 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

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! ✨

Footnotes

  1. Rate AI review example

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