A back water valve is what you need. These devices have a flapper valve in them that allow the water to leave the house but close when the city sewer water level tries to come into your home. The problem is that about 50% of these backwater valves fail over time. The flapper valves have a tendency to become stuck and even dislodged and stuck in the line. The best approach is to check the back water valve periodically. The back water valve should be the last plumbing valve/access before the drain line leaves the basement. I always recommend a flood check in the floor drains as backup safety valves as well. These floor drain valves only cost about $20.00, if you don’t have one get one soon.