I'm trying to restore my database backup and got this:
Gateway Time-out

The gateway did not receive a timely response from the upstream server or application.

Comments

jlea9378’s picture

Status: Active » Closed (won't fix)

Closing issue.

devad’s picture

Version: 5.x-1.3 » 7.x-3.x-dev
Component: Code » User interface
Category: Support request » Feature request
Issue summary: View changes
Status: Closed (won't fix) » Active

Hi

I have found this old issue which describes exactly what my current problem is, so I have decided to re-open it, rather than to create a new one.

When I run my database backup manualy (12MB) it takes about 60 seconds to make a backup.

If it takes 55 seconds everything is fine and I get a message that database is backed up sucessfully.

But if it takes longer then 60 seconds I get: 504 Gateway Time-out error

I have contacted my hosting provider (shared hosting) and they said that these errors occure when script is not comunicating with server for more than 1 minute.

So, my question is if there is some easy sollution for these 504 timeouts I am experiencing with Backup and Migrate module? (and with other parts of administration which sometimes take more than 60 seconds to complete)

If some kind of module with progress bar exists which can be easily implemented so that admin scripts maintain comunication with server during loger runs - or some other solution.

Any help or advice would be appreciated.

Thank you.

jlea9378’s picture

You might try increasing the script execution time in your php.ini file. 60 seconds is the default which can sometimes be insufficient.
max_execution_time = xxx
max_input_time = xxx

devad’s picture

Thnx jlea9378

I have both those values bigger then 60 seconds.

They are not reason for timeout.

The reason for timeot is the lack of comunication with server. The script is "doing it's job" without any communication with server and after 60 seconds server conludes that script is not there any more and gives 504 timeout error.

jlea9378’s picture

Are you using Apache with mod_php or php-fpm?
I've had timeout problems with php-fpm, that's why I ask.

devad’s picture

Apache + suPHP + MySQL

devad’s picture

Some kind of batch proces with progress bar inside Backup and Migrate would prevent such timeouts.

For example:

Completed about 30% of the backup operation.
Successfully backed up 60 tables out of 198

Or for restoring:

Completed about 40% of the restore operation.
Successfully restored 80 tables out of 198

Such progress bars would improve UI as well.

Is it (technically) possible to have such batch processes with progress bars inside B&M without compromising reliability of backup / restore functionality?

pierostz’s picture

I have the same issue with @devad. Whatever values I give to max_execution_time and max_input_time (which are 240sec the maximum allowed by my hoster), I get the same error.

I think this is always the case in big sites and there is no way to overcome this in these cases. The developer's insights are welcome on this issue.

P.S: The exact same issue happens also on the backup procedure and not only the restore.

devad’s picture

@pierostz. Yes, backup is problem as well, not only restore.

However, despite 504 error messages I just want to stress that backup and restore processes are finished successfully. If I reload backup and migrate page after few minutes I get the message "Database is backed up successfully." Restore works well also with message "Restore is done successfully." It is just 504 error message which confuse admins, so they don't know what is going on in the background.

pierostz’s picture

@devad. Aha I didn't realize that with refreshing the backup can finish up...but I agree that is not only confusing but not really a great solution having in mind that you have to press refresh several times...

devad’s picture

@pierostz #10

You don't have to to press refresh several times or to do anything for backup or restore to finish properly. You can go to sleep after you give backup or restore commands and they will be finished properly.

So, backup and restore integrity is not compromised by this error. It is just confusing to admins that they do not know what is happening after they get 504 error message.

After I have realized that everything is going fine with my backup and restore commands, I am not confused any more by 504 errors, but I am sure that many admins will panic just like me when they get 504 errors first time thinking that they can not complete backup or restore commands at their site any more.

By the way... my database is cca 32MB (gzip compressed) and it takes about 2 min 30 seconds for it to be backed up and about 7-8 minutes to be restored. I get 504 error every time exactly 60 seconds after I start backup or restore command.

pierostz’s picture

@devad Aha I didn't realize that refreshing doesn't matter anyway. I was one of those admins that is confused I guess. Thanks for the input.

devad’s picture

The backup and restore scripts are taking more than 1 minute to create or restore backup files, and my server's Apache timeout was set to 60 seconds.

The error is fixed by increasing TimeOut value inside httpd.conf file:

#
# Timeout: The number of seconds before receives and sends time out.
#
##Timeout 60
Timeout 600

However, for those on shared servers who doesn't have access to make such change it would be nice if Backup and Migrate module would have some mechanism to keep communication with server alive during long backup and restore processes.

ranelpadon’s picture

We have also this timeout issue, Error 504 page showing when backing-up or restoring the Upload Files folder and Entire Site when processing is longer than 1 minute (60 seconds). Backup and restore processes completed successfully though in the background and as indicated in the site logs/email notifs. Files to be backed up/restored are around
350MB only, and the process usually takes around 2 minutes according to the site logs/email notifs.

We tried these settings in php.ini:

max_execution_time = 600
max_input_time = 600
memory_limit = 2500M
post_max_size = 0
upload_max_filesize = 256M

and this Timeout setting in apache2.conf:
Timeout 600

After restarting Apache service, the issue is still not gone and no generated error logs. Moreover, it's quite surprising that it happens in our Prod site but not on its Staging version considering they have similar settings.

couturier’s picture

Status: Active » Postponed (maintainer needs more info)

@ranelpadon please upgrade to the newest 7.x-3.2 version released September 27, 2017, and see if this resolves your issue. This thread is very old, so it might be best to start a new issue with a condensed summary of what is happening -- filed against the newest version of code -- if it continues.

couturier’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Closing after more than two weeks with no activity.