Download errors, backup files contain trailing HTML, corrupts archive backups

Created on 16 August 2021, almost 3 years ago
Updated 3 April 2024, 3 months ago

Problem/Motivation

I install the 5.0.1 version in Drupal 8.9.18 using ddev and cant download a database only get the error:

Failed network - error

I found this log message:

access denied
Path: /admin/config/development/backup_migrate/advanced. Drupal\Core\Http\Exception\CacheableAccessDeniedHttpException: The 'perform backup' permission is required. in Drupal\Core\Routing\AccessAwareRouter->checkAccess() (line 117 of /var/www/html/core/lib/Drupal/Core/Routing/AccessAwareRouter.php).

See also 🐛 Backup files contain trailing HTML, corrupts archive backups Closed: duplicate for more debugging progress prior to this issue and possible issue credits.

🐛 Bug report
Status

Needs work

Version

5.1

Component

Code

Created by

🇲🇽Mexico koffer

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • Merge request !29Issue #3228379: Failed network - error → (Open) created by Grevil
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    8 pass, 2 fail
  • 🇩🇪Germany Grevil

    I applied patch #19 by @jillh68 and created a simple test.

    Unfortunately, the test results in Drupal still being in maintenance mode, after the backup has finished. Manually testing this will result in the correct expected behaviour... Maybe the test is missing something, I am unsure.

  • Status changed to Needs review about 1 year ago
  • 🇩🇪Germany Grevil

    Setting this to "needs review", maybe someone can fix the test.

  • Status changed to Needs work about 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    8 pass, 2 fail
  • Status changed to Needs review about 1 year ago
  • 🇩🇪Germany Grevil

    Tests were actually correct.

    The site will NOT leave maintenance mode, if the backup destination is set to "Download". But it WILL leave maintenance mode, if "Private Files Directory" is set as the backup destination.

    This is represented in the added test.

  • Adding related issue, since it was mentioned in #16 and #17 that downloaded files contain html.

  • Status changed to RTBC 6 months ago
  • After testing the MR, I can confirm that the applied changes fix the related issue with trailing HTML on downloaded backups!

    I will mark that issue a duplicate of this one. Thank you for the fix!

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 8.0 & MySQL 5.7
    last update 6 months ago
    8 pass, 2 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 8
    last update 6 months ago
    7 pass, 4 fail
  • Bumping priority to match that of the related issue.

  • Status changed to Needs work 6 months ago
  • 🇩🇪Germany Grevil

    Just found a bug, while fixing the last failing test. When downloading the backup, and simultaneously having "Take site offline" checked, the site won't go online after the download has finished.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 8.0 & MySQL 5.7
    last update 6 months ago
    8 pass, 2 fail
  • 🇩🇪Germany Grevil

    Taking a further look, the destinations "download" (and "upload" for some reason) are added through line 144-149 in backup_migrate.module:

    // @todo Make this better.
    if (empty($options['nobrowser'])) {
    // Add a download destination.
    $user = \Drupal::currentUser();
    if ($user->hasPermission('access backup files')) {
    $destinations->add('download', new DrupalBrowserDownloadDestination(new Config(['name' => t('Download')])));
    }
    // Add an upload destination.
    $destinations->add('upload', new DrupalBrowserUploadDestination(new Config(['name' => t('Upload')])));
    }

    I think, that is the root of the problem. "private_files" is generated through an install .yml file ("backup_migrate.backup_migrate_destination.private_files.yml"). Although I don't completely understand the workflow yet. I first thought destinations would be simply plugins, but they are not.
    The PluginManager calls all plugins "teardown" method, if they implement one. With private files this is no problem, but instead of destinations being plugins and having their "teardown" function bring the drupal site out of maintenance mode, destination seems to be something else, and instead the "DrupalUtils" plugin will get the site back online, but it only does that for private_files, even though we add the DrupalUtils plugin a few lines below of the before mentioned destination additions.

    No idea, we could disallow taking the site offline for both download and upload destinations as a quick fix. Everything else needs to be done by someone with further knowledge.

  • Should a test also be added to ensure that the related issue doesn't occur again? (Making sure that the downloaded backup is correct)

  • @Grevil, I think it would be okay to disable taking the site offline for download, for sure, since you can easily download the file afterwards at /admin/config/development/backup_migrate/backups.

    I haven't used the upload destination, so I don't know for that one.

Production build 0.69.0 2024