We could potentially do it over the span of millions of years. Not without risk though. And generally we would want to move further from the sun when it reaches a later stage in its life and starts to expand. https://en.m.wikipedia.org/wiki/Moving_Earth