Skip to content

Implement nightly backup and restore procedure in task.sh#150

Open
Petliuk wants to merge 3 commits into
mate-academy:mainfrom
Petliuk:solution/backup-restore-databases
Open

Implement nightly backup and restore procedure in task.sh#150
Petliuk wants to merge 3 commits into
mate-academy:mainfrom
Petliuk:solution/backup-restore-databases

Conversation

@Petliuk

@Petliuk Petliuk commented May 18, 2026

Copy link
Copy Markdown

No description provided.

Co-authored-by: Cursor <cursoragent@cursor.com>

@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 script has a critical execution error that prevents the backup/restore operations from completing. The error ERROR 1046 (3D000) at line 22: No database selected occurs because the mysql restore commands do not specify which database to use when executing the SQL dump file. When restoring databases with mysql < /scripts/backup.sql, MySQL needs to know which database to target. Your script uses sed to replace database names in the dump output, but doesn't tell mysql which database to restore into. To fix this, add the database name as an argument to each mysql restore command. For example: mysql -u "$DB_USER" -p"$DB_PASSWORD" ShopDBReserve < /tmp/full_backup.sql or use the -D flag: mysql -u "$DB_USER" -p"$DB_PASSWORD" -D ShopDBReserve < /tmp/full_backup.sql. This is blocking because the backup operations complete successfully, but the restore step fails for all three databases. Once you specify the target database in the restore commands, the script should execute end-to-end.


✨ 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

Petliuk and others added 2 commits May 19, 2026 00:18
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

@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 correctly implements all task requirements: it reads DB_USER and DB_PASSWORD from environment variables, creates a full backup of ShopDB and restores it to ShopDBReserve with schema and data, and creates a data-only backup (excluding schema) for ShopDBDevelopment. The critical issue that was present before—missing database name in mysql restore commands causing ERROR 1046—has been successfully resolved by specifying the target database as an argument to each mysql command. All 18 checklist items pass, and the pipeline approach used for both backup and restore operations is clean and efficient, making it suitable for cron job execution. Great work on fixing the database name issue and ensuring the script meets all requirements.


✨ 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