Recovery HAProxy Config file

During the process of editing the haproxy.cfg file, I accidentally lost all the information in the file. Currently, I only have an old backup file and the HAProxy stats page is still operational. I would like to ask:

  • Is there a way to retrieve all the information from the running HA service and restore the haproxy.cfg file?
  • If not, how can I find the corresponding port numbers for the services listed on the HAProxy stats page? The stats page only provides information about the IP addresses of each service.
    Thank you very much!

Wouldn’t running something like netstat -anp | grep LISTEN give you what you’re looking for, since you know the IP addresses?

1 Like

Thank you but this command can not show me what is the service name of each particular port.

So you mean the front end / back end elements listed on the stats page? I would submit that may be a matter of trial and error, but it would start with netstat to see what ports are being listened on the HAProxy box to give you the front end, then logging into each backend IP to match things up. If you know the backend targets and those targets are each unique per “service” then you should be able to tie them together with a little detective work including the old backup config file you have. Anything listening but not in that old config file you’d have to log into those servers and dig into further, and you obviously wouldn’t know anything about rate limiters or other stuff, but hopefully that’s in your old file.

I’m not aware of any way to extract out of memory what HAProxy is currently “doing”. The only other way out there thing to look at is if there was a vi crash file (assuming you were using vi or vim).