Sorry to resurrect an old thread. I ran into this issue today and have found a resolution (at least in my case).

I had an image that was quite old that I wanted to update. The client I wanted to image was from a completely different system (a VM). I cloned over top the existing image with the VM. I got the same exact 504 error and it would eventually fail to update the database.

I created a new image in fog and assigned the new host that new image. Went through flawlessly.

It’s weird because I’ve done this in the past on multiple occasions and never had an issue. It was more than likely I created the older image (that I was just trying to clone over) on v1.5.9. I did update to v1.5.10 a couple months ago.

So if you have this same problem, try creating a new image if overwriting an old image fails with the 504 error.