504 error when running Managed Backup

Managed Backup returning 504 Time Out Gateway error. Manual Snapshot when including all files and full databases shows the same error. When running manual Snapshot backup, the 504 shows when backing up plugins. Smaller backup files that included only a database, or only media files and only plugins and themes can complete successfully.

  • Adam Czajczyk

    Hello Massimiliano

    I hope you're well today and thank you for your question!

    I checked the site and I think this is related to server resources. On some shared hosts the "bottleneck" is an I/O limit (Input/Output) which basically means that there's a limited number of file read/write operations with some time-frame. Snapshot, due to its nature, does a lot of reading and writing to files in order to create backups and if those limits are being reached, the server might just be cutting the scripts of. There is a chance also that it's not terminating scripts but just slows down and that would also result in a timeout (504) error.

    I think we could try to overcome it by making three changes to the configuration first:

    1. in your cPanel you should have an option to switch PHP version for a domain.

    The site's currently running on 5.6.x and while Snapshot is compatible with it, the 7.x version is faster and "lighter" which usually means less "load" on a server. Take a look, please, if you can switch it - 7.x (preferably 7.2.x) would be a good choice.

    2. the other change would be PHP "max_execution_time" option setting.

    Currently it's showing the value of "0" which in theory means unlimited but it rarely is, especially on shared hosts. Usually, it actually means 30 or 60 seconds which in most cases is too short time for Snapshot to process backup files. The Snapshot doesn't report it because it "sees" 0 value and assumes that the time is indeed unlimited (as it should be) but that's something that might need tweaking here.

    I'm not sure exactly about SiteGround but I believe that in cPanel after you switch PHP version you should also have an option there to change PHP options (probably a MultiPHP INI Editor tool). It should let you find the "max_execution_time" option and if so, try setting it to a value of around 160-180 (or, if it allows you, try 300).

    3. Finally, try raising WP memory limit a bit more. It's currently set to 256M which should be more than enough but raising it further might give the scripts even a bit more "space" to complete, lowering the load on server even more. You can do it by finding this line in a "wp-config.php" file:

    define( 'WP_MEMORY_LIMIT', '256M' );

    and changing the 256M value to 512M.

    Once that's done, make sure to clear all possible caches - on site but also there should be 3 types of cache in SiteGround panel. They are all under one caching option, just additional tabs there - if they are enabled, clear them all.

    Then check Snapshots (both Snapshot -> Snapshots and Snapshot -> Managed Backups) and see if the issue is still happening. It would also be good if you could check your site's traffic stats before doing that and try to check it when the traffic to the site is on its lowest level.

    Let me know about results, please.

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.