Keep Consul Service Mesh sidecar job running for post stop job

Okay so I have a periodic job that I want to use for creating backups of game servers, for this I wanted to split this into 3 tasks

  • a prestart task that signals the game to disable auto-save temporarily and save the game right now
  • then the main task, performing the backup itself (snapshot, replicate to the cloud, whatever, …)
  • a poststop task that will enable auto-save again and send message that the backup has been completed

However I communicate with the game server using consul’s service mesh, which works fine for the prestart and main task, but the sidecar task gets stopped before the poststop tasks gets to run, leading to a connection failure as it can’t use the service mesh anymore.

Is there a way to have the sidecar task run until the very end of the allocation or how should I go about structuring this workflow better?

The tasks all need different docker images so combining them into one single task running a script seems less ideal as I would need to create a custom larger docker image just for this one single task