In the US the Corps of Engineers manages the nations inland waterways as a civil defense function. They have some 38000 military and civillian contractors employed at this. The CoE also manages a lot of the nations hydroelectric power generation.
In war time if the US were invaded, areas falling under military operations would be immune to posse comitatus but other areas would not be. Active military operations would be by the US military active, guard and reserve while the rear areas would fall to the states including state militia forces and law enforcement supported by federal law enforcement. But that is highly unlikely... the distances are too great. But the same structure can be used in the event of a major social collapse.