Generator hook-up

I ran across this panel at a recent inspection. The feed wire is 10ga, coming from a 2 pole 30amp breaker in the main panel, labeled water heater which in turn feeds the water heater thru the 30 amp breaker on the left which doesn’t seem to be a problem. Numerous other problems in the panel can be found and commented on but the one item of concern that I was not certain of is this:
The 50 amp breaker and wiring on the right feeds a pole barn/garage but as I see it could only receive 30 amps of power due to the 30 amp breaker in the main panel. Again, no problem?
In the pole barn however, is a generator hook-up that is set-up to back feed power thru this 50 amp connection at this panel and back up to the main panel thru the 10ga wire and 30 amp breaker.
My question is, does this 30amp breaker in the main panel protect the 10 ga wire or is there potential to overheat this wiring?
My comment was: "In my opinion, this would create an unsafe condition and I would advise that this system not be used until a qualified electrician reviews and approves this set-up."
Would welcome any comments on the generator set-up thru this panel.

I think you did well, Gary. I see generator back feeds occasionally, and this is not “Professional”

By the way, we havnt met, Welcome to NACHI. How long have you been a member? We are not far out of each others districts.

The lack of an approved tranfer switch or interlock device is a definite safety issue.

Correction is definitely needed.

I agree, as well as the individual conductors feeding the 50 amp CB.

It does not look like the neutrals and grounds are properly separated either.