Cited as a reference · for some experience
Automatic generator changeover switch (with schematic).
Why people recommend it
Cited as a look at a ready-made automatic transfer switch for changing between mains and generator, and as an example of the usual approach.
Watch for: Mains and generator wiring can kill, including by feeding power back into the grid; follow local rules or use a qualified electrician.