These are two different problems:
1) keeping the earth alive with its fauna (us included) and flora
2) preserving human civilization
If we do not blow ourselves up into a stone age at regular intervals the technology will be developed for 2, i.e. a space age a la science fiction stories, even looking for other habitable planets . There will be time enough to build Arks.
1) is less feasible, though technology might advance enough, again if we do not blow ourselves up with successive nuclear wars,to find a way. Maybe use the magma layers to heat enough mass and create a directional jet to space that will gradually propel the earth to a more distant orbit continuously compensating for the increase in heat from the red giant . As there will be thousand of years warning maybe the engineering will become feasible, like space elevators. This is really science fiction.
In any case at some point the universe will blink out and there will be no solutions.