The safest. and, only approved way to connect a portable generator to your home electrical service for backup power use is through a generator inlet box and transfer switch.
Portable generators provide the benefit of being multi-use. Bringing electricity into an off grid area is the main function, but many portable generator owners want to leverage their investment by using the unit as a home backup unit. This is acceptable, but only when installed correctly.
Without a generator inlet box, cord, and transfer switch or lockout kit, connecting your portable generator can violate electrical codes, damage devices connected in the house, and be very hazardous.
Backfeeding is a dangerous condition in which power from your generator is fed back into the electrical system through a standard outlet. In all cases, it is against the electrical code. By backfeeding, a generator connected to the home could send power through the whole house, out the meter and onto the electrical grid, possibly injuring or killing workers who would come in contact with live wires. In most cases, 1) the extension cord is not heavy enough gauge wire to carry the full load and 2) the portable generator is not powerful enough to power the whole system.
A generator inlet box, connected to your circuit breaker panel through either a breaker with a lockout device or a manual transfer switch is the safest way to power your home in time of a power outage with your portable generator.