With the 'Take site offline' checked in the 'Advanced Options' in 'Settings Profile' the site correctly goes into maintenance mode and displays the offline message, but even though the scheduled backup completes correctly the site fails to come out of maintenance mode. Backup and Migrate email notifications are enabled and success email is received:

The site backup has completed successfully with the following messages:
Site was taken offline.
Site was taken online.
Entire Site (code, files & DB) backed up successfully to CronTest_Full-Backup-09-12-14_17-20-02 (13.09 MB) in destination Scheduled Backups Directory in 2 sec.

This is being tested on a clean install of Drupal 7.34 with just Backup and Migrate and Elysia Cron modules installed beyond core. 'Never / Use external crontab' has been selected in 'admin/config/system/cron/settings' and cPanel on the host server configured to load cron.php with the cron key every 5 minutes.

Having searched open bug reports I believe this issue was reported for Drupal 6.x versions, but is not currently reported for Drupal 7.x.

Comments

Synflag’s picture

Drupal 7.33 / Backup&Migrate 3

Site visitors Nov 30, 3:00 am: 0 visitors

eMail from B&M / Nov 30, 2:16 am:
----------------
Die Sicherung der Website wurde mit den folgenden Nachrichten erfolgreich abgeschlossen:
Site was taken offline.
Site was taken offline.
Site was taken online.
Site was taken online.
Your backup has been saved to your NodeSquirrel account. View it at http://manage.nodesquirrel.com/backups/159ecb665a0a3e....
Standard-Datenbank backed up successfully to CUSTOMER-2014-11-30CET02-15-39 (217.71 MB) in destination NodeSquirrel in 1 Minute 1 Sekunde.
------------

Best regards

Lars Jendrzejewski

Edit 08. Dez 2014:
Message after manual backup:
-------------
Site was taken offline.
Site was taken online.
Your backup has been saved to your NodeSquirrel account. View it at http://manage.nodesquirrel.com/backups/9d63fa9thde1e52b665afgjf3e
Standard-Datenbank backed up successfully to CUSTOMER-2014-12-08CET01-07-56 (217.15 MB) in destination NodeSquirrel in 1 Minute 20 Sekunden. (herunterladen, wiederherstellen, Löschen)

Die Website befindet sich im Wartungsmodus. Online gehen. <<<<<<<<<--- Maintenance Mode
-------------

Anonymous’s picture

same here. DB only is working.

giumas’s picture

I got the same issue on Centos 6.. I have attempted by update both Drupal 7 and B&M to the last release, but not luck!

I confirm that the `DB-only` mode works as expected!

Wolf_22’s picture

Same issue here... I'm assuming this would be by design but it defeats the purpose of allowing the option for scheduled jobs. (What I mean is that it doesn't make a lot of sense to provide this as an option in schedules if the backup process doesn't come out of maintenance mode.)

Using 7.x w/ lastest B&M.

maxklimenok’s picture

It seem to me that I know how to solve the problem.

In file sites/all/modules/backup_migrate/includes/filters.utils.inc on line 207 there is a take_site_offline() function which is responsible for putting site in the maintenance mode.

The function works fine until under certain circumstances it is fired (called) twice or even trice in a row. I figured this out by applying timestamp on line 217 and line 231.

_backup_migrate_message('Site was taken offline. ' . time());
_backup_migrate_message('Site was taken online. ' . time());

So in backup confirmation e-mail instead of
• Site was taken offline.
• Site was taken online.
• База по умолчанию backed up successfully to moneycookbook.org-2015-03-16T18-39-38 (49.23 МБ) in destination Manual Backups Directory in 6 сек..

I have got the following
• Site was taken offline. 1426520378
• Site was taken offline. 1426520379
• Site was taken online. 1426520381
• Site was taken online. 1426520385
• База по умолчанию backed up successfully to moneycookbook.org-2015-03-16T18-39-38 (49.23 МБ) in destination Manual Backups Directory in 6 сек..

The problem is that the function (on line 209) gets and stores the current on/off-line state of the site and changes it at the same time (on line 216). Then the state is restored later (by take_site_online() function) when backup procedures are finished.

When the function is called once – everything is fine and works as follows: site is online -> the function remembers “on-line” status and puts site offline -> back-up procedures -> initial “on-line” status is restored.

However, when the function is called twice or more in row, the following happens:
site is online -> the function remembers “on-line” status and puts site offline -> now, when it is called for the second time it overwrites initial “on-line” save with the current “off-line” status, and does nothing because the site is already in the maintenance mode -> back-up procedures -> “off-line” status is left as is.

To solve the issue I have altered line 209 as follows:

if (!isset($this->saved_site_offline)){$this->saved_site_offline = variable_get('maintenance_mode', 0);}

Now, when the function is called several times in the row it remembers only the initial state of the site once. Everything works fine.

Sorry for my writing style and probably not the best solution for the situation (the solution only solves the symptoms not the roots of the problem which is the double function call) but I’m not the programmer and it would be difficult for me to investigate further. In addition, I’d like to ask someone to submit the patch.

ronan’s picture

Title: Site doesn't come out of maintenance mode » Site doesn't come out of maintenance mode when backing up entire site

  • ronan committed def9c09 on 7.x-3.x
    Issue #2390057: Site doesn't come out of maintenance mode when backing...
ronan’s picture

@maxklimenok You are correct. This function does not do well when called multiple times, and that's what happens when you do a full site backup (backing up the DB first and then the code and files).

I have applied a fix to that function so that it only runs when the site is currently online. That seems to fix the issue.

ronan’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.