Prevent global values to get reset on update

For ESPhome there are often updates available, when installing them, the whole firmware of the sensors get’s recompiled and also the configuration get’s reapplied to the sensors.
As i use a global value as persistance for count values like gasmeter, powermeter, watermeter, etc. their values get reset to the value i once added to set the start count.

globals:
  - id: total
    type: int
    initial_value: '1234567'
    restore_value: false

How can i prevent that the value get’s reset or lost?
Where is it saved anyway? Inside HA or inside the sensor?

It’s saved in the flash memory of the ESP device. Update your initial values before performing the ESP device update.

Ah, ok, means that this value of ID “total” is stored inside my ESP-node non-volatile memory. Means that HA only get’s the value from there, but don’t store it himselfs, right?

If i comment out the “initial_value” param, would that help?
What is the “restore_value” used for?