Backup error in Openemr-5.0.1(2)

I had this error on backup today .
Gateway Timeout
The gateway did not receive a timely response from the upstream server or application.
OS : Fedora 28
Server : PHP7 Mariadb
Browser Firefox

Any advice and solution would be appreciated.

Jack

This likely happened because the PHP script handling the backup took longer then the webserver allows. Hopefully the PHP script continued to execute. There are a couple of ways around this. First, if you run the PHP backup from a script that is being executed form the command line you should be ok. This is the safest as you wouldn’t have to change your webserver timeout settings. If you want to run the backup through the web server you’d need to change the timeout setting in your webserver. I assume you’re running Apache?

Hi @jackfruit501 ,
What is your memory_limit setting in php.ini config?
-brady

I would appreciate a bit of handholding for this.

memory_limit = 526M in thd php.ini

Hi @jackfruit501

Just to give you more info on this bug, check out this issue ticket, of which ideal fix is under discussion:

A key take home point is that it looks like the backup zip has been created on your server (so, can get to it via your local terminal on server), however it is running out of memory when it tries to download file via web browser. Hopefully can find file at <temp_files_directory_set_in_global>/openemr_web_backup//emr_backup/

-brady

Solution try

I could not locate the emr_backup.file. I had to do a manual backup wih mysqldump as shown in the excellent howto documentation. Maybe patch 3 will incorporate a fix.

Thanks .

Jack

Hi @jackfruit501 See my solution above if you want to go ahead and patch now. It’s just one line in interface/main/backup.php. However, Brady indicated he will get in next patch if you wish to wait.

Thanks. Will wait for patch 3.

Updated fix with patch 3. Problem persist with inbuilt backup on Fedora 28 and Firefox 60.0
64Bits. Newest Mariadb anf PHP used.

Hi Jack, I had high hopes this fix worked across all platforms. I only tested against setting memory limit to 128M with a 300M download. I can’t see why Fedora would make a difference. How large is your backup? You say newest PHP, does that mean PHP 7.1? Are you sure it fails for out of memory or perhaps it fails with script timeout. What are your php.ini settings for max_execution_time and memory_limit?

Hi Jerry,
The php.ini shows

max_execution_time = 90
memory_limit = 256M

mariadb.x86_64 3:10.2.14-1.fc28
php.x86_64 7.2.6-1.fc28
Firefox 60.0.1(64bits)

Same data using LinuxMint 18.3 for backup the size of emr_backup.tar is 127.5MB

Hope this helps.

Jack

Perhaps PHP 7.2 handles memory different or same in a different way:) I stopped trusting PHP after 7.0 as they’re trying hard to stay relevant. Though the backup script turns off script timeout it works different for say windows compared to linux when streaming from a script even via a header download but you should not be timing out for a 128M download unless you have an intermittent connection.
Before I rewrite to a streaming download i’d like to get more information if you’re willing.
Are there any errors in error log or console that may give a clue. Also would love to see if anyone else has had this since patch.

Hi Jerry,

I am willing to do the needful .
Which error log should I enclose?

Jack

@jackfruit501 New PR with a rewrite to chuck stream download. I’ve tested very large downloads so should work for ya.

1 Like

Heads up - If you have a reverse-proxy (load balancer) in front of your system, ensure your connection idle timeout settings are configured to allow for the time it takes to dump the database. Upwards of 30s, 60s, or more depending on your database (connection, performance, size, etc.).

::ahem:: https://demo.openemr.io/ :smile: