Problem/Motivation
When we currently restore the default Drupal database, a status message appears noticing the user about the successful restoration of the database.
This notification will not show up under the watchdog page ("/admin/reports/dblog"), since the restoration message will be logged first, but reset afterwards by the restoration process
Steps to reproduce
- Restore the default drupal database via uploaded backup file
- See the status message "Restore complete ..." on page after restoration
- Check if the status message is shown under "recent log messages in "/admin/reports/dblog"
- The status message is not there
Proposed resolution
Log the restoration message after the watchdog reports get reset.
The log entry should include information about:
- What was restored (backup name)
- Status of restore (success, ...)
- When it was restored
- Who restored
Additionally, we could discuss if a "Description / note" would also make sense on restore like on backup creation. This could also simply be logged with the watchdog entry!
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 3305094-restore-msg.png | 92.27 KB | danrod |
| #19 | 3305094-restore-msg.png | 92.27 KB | danrod |
| #17 | Apply-MR-3305094.png | 795.81 KB | nikhil_110 |
Issue fork backup_migrate-3305094
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
anybodyImportant point to see restores in Watchdog! Wondering this wasn't done yet.
I added some details and ideas for the log entry.
Comment #4
tamerzg commentedComment #6
tamerzg commentedAdded status message to Drupal log:
Restore completed using {backup_name} from {backup_location} into {destination} at {time}.
Comment #7
anybodyThanks @tamerzg - I added two comments. LGTM at all. Could you explain your choices?
Comment #8
tamerzg commented@Anybody thanks for the review. I replied inside PR.
Comment #9
anybodyThanks, moving both into the t() is just what I expected. Perfect! :)
Comment #10
tamerzg commentedComment #11
tamerzg commented@Anybody I just updated PR, now $message string is built dynamically so we don't mix it with context variable. Please note that $message is not wrapped in t() as it shouldn't be, log messages are translated on display, but they are always stored in english/system language.
Comment #12
anybodyI personally don't really like this cluttered text approach, but other maintainers may see it different. Let's wait for further feedback.
Comment #13
grevil commentedOK, I think this needs further work.
I agree with @Anybody. Not really a fan of the concatenated string approach. Furthermore, the log message text doesn't display the correct parameters.
For the test, I made a backup of my site using the backup_migrate module and saved the backup in my private files directory. Afterwards I used the "Restore" option.
This is my file dir / name :
files/private/backup_migrate/backup-2023-02-13T10-35-05.mysql.gzAnd this is the log message result:
Comment #14
grevil commentedNot really the expected outcome, but fairly close! :)
Comment #15
grevil commentedUpdate: The incorrect message only appears when restoring a backup using the "BackupMigrateRestoreForm" ("/admin/config/development/backup_migrate/restore" => the one with the file upload field). But the message appears correct, when restoring through the "BackupRestoreForm" ("/admin/config/development/backup_migrate/backups").
The reason behind this is, that inside "BackupMigrateRestoreForm", "backup_migrate_perform_restore()" is called with hardcoded parameters for correct file usage of the file uploaded in the file upload field.
Since this is working flawless for the "BackupRestoreForm":
And we can not easily get file and destination IDs through the "BackupMigrateRestoreForm" without heavy refactoring, I suggest, we either display a static log message, keep it as is or remove the logging if the restoration was performed through the "BackupMigrateRestoreForm".
Any other ideas or an easy fix for this problem are also welcome! :)
Comment #16
grevil commentedComment #17
nikhil_110 commentedThe above MR is applied successfully for Backup and Migrate v5.1.x-dev.
Attaching the screenshot for reference.
Review Step
The Backup is still not added in the log message as was suggested by @Anybody in #2.
Review it too and let know if that is required.
Comment #18
xmacinfoUsing Backup and Migrate 5.0.3 to restore a file (related to issue https://www.drupal.org/project/backup_migrate/issues/3264580), using the file picker, I expected to see a confirmation message.
I did not see any message on the screen.
In searching for another confirmation I looked at the watchdog and I did not see any entry related to restore or any Backup and Migrate entries.
The only way I was able to confirm that Backup and Migrated did the restore successfully was to look at the content and check for recent changes.
Comment #19
danrodTested this MR for 5.1.x and I can see the confirmation message after I restored an old backup, can be moved to RTBC.
Comment #20
danrodI rebased the branch and tested the changes again and I can see the log message in watchdog table, setting this to RTBC and merge it to branch 5.1.x
Comment #21
danrodComment #23
danrod