How to run ground, for electric supplied by generator and batteries through a inverter
You are the electric utility -- thrice over!

Your configuration, with a generator and an inverter/charger, requires special care as you have not one, not two, but three electrical systems, all isolated from each other and completely off the mains electrical grid.  This is outside the norm for a residence, and requires careful application of the NEC rules for separately derived systems starting in 250.30.

Start with the easy stuff first

The easy part of this all is making sure that all the panelboard (aka load center/electrical panel) cabinets, the inverter's safety earth terminal, and the generator frame are all solidly connected together.  This makes sure you have an effective fault-current path everywhere it's needed as per 250.4(A)(5) and 250.92.  These conductors can be sized as per 250.122 in your case due to 250.102(D) and this rule from 250.32(A)(2):


  A supply-side bonding jumper shall not be required to be
  larger than the derived ungrounded conductors.


Getting down to earth (ground)

You'll need a grounding electrode, of course.  This defaults to the metal-cold-water-pipe electrode (or structural steel, but you don't have that) in 250.30(A)(4), but I'd put another 250.52(A)-compliant one in to protect against plumber-induced losses of grounding, as they can leave your system completely floating which is a problem if lightning strikes nearby.

Since you have multiple separately derived systems, though, this is where things get hairball.  You'll either need to:


Run completely separate grounding electrode conductors from the generator grounding electrode attach point and inverter AC output bonding point to each of your grounding electrode(s).  This is straightforwardly permitted by 250.30(A)(6), but can lead to a proverbial spaghetti bowl of grounding electrode conductors, a minimum of four in your case, all of which must be at least as large as required by 250.66.
Or, run a single grounding electrode bus conductor between all the grounding electrodes and then tap it with 250.66-compliant conductors to feed the various grounding electrode attach points.  This bus conductor must be enormous though, as 250.30(A)(6)(a) requires it to be a minimum of 3/0 copper or 250kcmil aluminum.  That's the same size as a 200A service conductor!


In any case, you'll need to use listed grounding clamps or exothermic welds to make all grounding electrode and grounding electrode bus connections.

Bonding it all together

You'll now need to make sure that your supply bonds are in the correct places, and nothing's cross-wired between your grounds and your neutrals.  This means that you will need to practice good ground bar discipline -- both of your panels must have separate ground and neutral bars, with all the neutrals going to the neutral bar and all the grounds going to the ground bar.  Typical residential-sparky-in-a-hurry slobbering of everything onto one bar will not fly here!

First, the generator in your case is supplying the ground-to-neutral bond for its part of the system.  This means that you must pull the service bond out of the panel for the generator-powered stuff, wherever it might be (on a modern panel, it'll be a green screw in the neutral bar).  You will also need to install a ground bar kit into the panel if one is not present already and transfer all the ground wires to the new ground bar.

Second, thankfully, since you are dealing with a 24V DC system that is derived from a grounded AC system by a rectifier (battery charger), you don't need to bond the DC system to ground (as per 250.162(A) including Exception 2).  I would make sure that any metallic, non-current-carrying parts that may short to the DC system, such as metal battery racks, are bonded to the generator (inverter/charger AC input) system ground, though.

Finally, since your inverter's AC output is floating, you'll need to bond it to ground somewhere as per 250.20(B) point 1.  This can either be at the inverter with a jumper from the inverter output to both the inverter safety ground terminal and the grounding electrode conductors for the inverter system, or at the panelboard using the green screw or link (i.e. configuring the inverter-circuits panelboard as service equipment) as well as terminating the grounding electrode conductors onto the panelboard ground bar instead of the inverter bonding jumper.