Implement nightly backup and restore procedure in task.sh#150
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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! ✨
No description provided.