https://trn.trains.com/news/news-wire/2021/01/04-wabtecs-flx...
Miles of cable along the track is something the big railroads have looked at. If fuel goes to (and stays at) $8/gallon they will do it. Right now it isn't worth it, but the costs are easy to analyses.
The above is for freight rail. For passenger rail electric lines work out different, no serious operator of passenger rail uses anything else. Tourist attractions (generally running steam) are not serious. Diesel engines can be a useful backup for when wires break. Diesel is also useful on marginal lines that are only run at all because they already exist, but you would never build. Everything else - probably the majority - is incompetence.
In reality, this doesn't happen -- the capital cost of idle diesel locomotives would negate (and more) the money saved with the electric trains.
If catenary is damaged in Europe (usually by storms), rail services are suspended until it's repaired. Repair is a very high priority.
(For one thing, it's unlikely to be safe to repair the catenary if trains are still running.)
https://www.toshiba.co.jp/infrastructure/en/topics/back-numb...
https://www.raildeliverygroup.com/about-us/publications/acop... §6.1.4 says the UK rail network "never" lost power supply up to 2017, but...
Two years ago, a 45 minute cut to railway power in South East England led to a £10 million fine to the power companies: https://www.theguardian.com/business/2020/jan/03/three-energ...
The PDF also points out that a diesel backup is generally useless, since the line is blocked by the stuck electric trains.
I assume that just putting miles of cable along the track is more cost-effective, but it can't be used everywhere.