Problem/Motivation
Restoring a saved backup via the UI fails. A status message is seen "The file could not be imported."
The actual backup files are okay and can be restored via the restore button or manually.
Tested on a Mac with both DDEV and MAMP . Also tested on Linux with DDEV.
Update: This issue seems to affect all users regardless of server configuration.
Steps to reproduce
- Install Drupal 8.7.7+ or Drupal 9
- Install backup_migrate 5.0.0-rc2
- Configure private files directory in settings.php
- Enable backup_migrate
- Take a backup and save to private files directory
- Attempt to restore from the Saved Backup tab
- Backup fails with on-screen message: "The file could not be imported." No error messages are visible in logs.
Issue fork backup_migrate-3166166
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
mrpauldriver commentedComment #3
ikit-claw commentedI can confirm the exact same issue.
Also for the encryption I get prompted for a passcode? I see no obvious documentation on this. We need to add documentation if we are going to encourage use of encryption for future use.
I will have a word with Damien next week Paul.
Comment #4
devad commentedMy private files directory is not set outside of web root:
$settings['file_private_path'] = 'sites/default/files/private';in settings.php
And I am experiencing the same issue on restore attempt still.
Red colored message is displayed inside admin message area:
"The file could not be imported."
The strangest thing is that there is no any log error message recorded in drupal dblog or at server.
Here is part of code displaying the error message:
src/Core/Main/BackupMigrate.php at line 150:
I was able to var_dump() $file object passed to importFromFile() method and here is the var_dump($file) output:
Maybe someone will figure out from this output why
$source->importFromFile($file);failed.This is out of my knowledge scope. :)
My config: PHP 7.3, BAM v5.0.x-dev, CLOUDLINUX 7.8
Comment #5
devad commentedWith latest RC2 today the message at shared server online is the same "The file could not be imported." without any log error message.
Locally at my wamp server the message is: "Cannot open file".
And there is an error log message:
Warning: fopen(private://backup_migrate/): failed to open stream: "Drupal\Core\StreamWrapper\PrivateStream::stream_open" call failed in Drupal\backup_migrate\Core\File\ReadableStreamBackupFile->openForRead() (line 88 of D:\wamp\www\mysite\modules\contrib\backup_migrate\src\Core\File\ReadableStreamBackupFile.php)But this could be related with my local wamp settings... or not...
Comment #6
devad commentedMaybe it would be good to add this issue to RC2 release notes "Known issues" list together with current:
Known issues
#3154716: Unable to delete backups
Comment #7
devad commentedTemporary workaround for this issue is to download backup file and upload it at "Restore" tab (
admin/config/development/backup_migrate/restore).No error messages in this case and the backup is successfully restored.
Comment #8
devad commentedComment #9
mrpauldriver commentedBased on workarounds, basic functionality is not broken, but pushing ahead with RC releases seems wrong.
Comment #10
jasonluttrellWhen I go to the Saved Backups page at /admin/config/development/backup_migrate/backups I get a WSOD that says "The website encountered an unexpected error. Please try again later." Logs report:
And...
Is this the same issue that others are having here?
Comment #11
devad commentedRe: #10
Yes. The same error message.
There is a temporary workaround. You can download the file and restore it back by uploading it using the "Restore" tab.
Comment #12
jasonluttrellThanks for the reply. That's assuming one has access to those saved backups. In my case, the screen crashes. So, one has to use the command line to access those files. This seems like a problem that needs to be fixed.
Comment #13
jasonluttrellThis may be a related issue: https://www.drupal.org/project/backup_migrate/issues/3169587
Comment #14
gisleI am experiencing this as well.
I have a different report in logs than #10. Mine says:
This happens both with the latest development version, and the tagged release 5.0.0-rc2.
Is it not an permission issue with the private file system, as version 8.x-4.1 works as one would expect with the same private file system as source.
My environment:
- Drupal: 8.9.10
- Ubuntu: 20.04 LTS
- PHP: 7.4.3, 128M memory limit.
- MySQL: 8.0.22-0ubuntu0.20.04.2
Comment #19
fjgarlin commentedI just submitted a PR (first time using the feature!) to address both this issue and #3154716: Unable to delete backups.
The reason why download, restore and delete were failing was because the path contained a file name, so Drupal interpreted that as a direct path to a file and was trying to serve it, but the file doesn't exists on that location. I'm replacing the "." in the path for "-DOT-" so the path can be evaluated by Drupal's routing mechanism and therefore backups can be deleted, restored and downloaded again.
There was also a typo on a parametre name for the restore and delete confirmation pages which I've also amended.
I hope it all helps.
Comment #20
damienmckennaNice fix, thank you.
Let's add some test coverage to make sure the delete function works correctly.
Comment #21
damienmckennaAm adding test coverage in #3154716.
Comment #22
gisleI've tested the merge request introduced in comment #19, and can confirm that it works with 5.0.x-dev. Thanks!
Adding tests would be nice, but since RC2 of this project is in effect broken, I humbly request that this is committed, and that the addition of tests for this is tracked in another issue.
Comment #23
Christopher Riley commentedCould we possibly get an updated Dev version out there?
Comment #24
damienmckennaThe bare fixes were committed elsewhere, so let's work on trimming this back to focus on improving the logic.
Comment #25
damienmckennaThis doesn't need to be in the 5.0.0 release.
Comment #26
damienmckennaThe changes need to be improved upon, hence the status "needs work".
Comment #27
gisleCould you please edit the issue summary to highlight what the proposed changes are (that can be improved upon).
What I see in the issue summary is no "logic", it is just a bug report that I believe no longer can be reproduced if you run the latest dev snapshot. I think the PR in #19 fixed it, but it may also been fixed elsewhere. re. # 24. No changes are proposed in the issue summary, and it is hard to figure out if there are changes to the logic proposed in any of the many comments.
I love this module, and want to help out, but a little clarity would be nice.
Comment #28
graysonecooper commentedI'm also encountering this on trying to import/upload manually through the UI (as suggested in #7).
I've used both 5.0.1 and 5.0.x-dev on DDEV (WSL2) and have updated php.ini values to be well above the export size (compressed backup is <12MB and have limits at 200MB). Error logs only show warnings for using a temporary file: "a client request body is buffered to a temporary file."
Edit: Issue was that my local environment was setup to use mariadb, not mysql - changing ddev settings resolved the issue!
Comment #29
selinav commented#28 What values have you changed on your php.ini ?