There really is no one-size-fits-all solution, except for having an energy mix of renewables, with existing thermal power on standby.
Everything else will be covered by renewables + battery.
Which had already happened a few times across big parts of Europe, with weeks of overcast and low wind weather.
Specifically for Spain, a better backup wil probably be more interconnects with France and their stable nuclear power.
The UK was very very close to a blackout last winter for this exact reason. If Denmark weren't able to suspend maintenance on part of their grid to max out the Viking HVDC (it was running at half capacity) there would have been loss of supply. Potentially contained to one region and temporarily but it's hard to say for sure.
What's worse is the communication from NESO (now government owned, very recently) was downright misleading to how close it came.