The first step in fixing a sagging roof is to identify the cause of the sag. In most cases, a sagging roof is caused either by a broken rafter or roof decking, but in some more severe instances, a damaged or sinking foundation can be the underlying cause of the problem. You will need to get up into your attic and examine the roof carefully in order to discover the underlying cause. Once you have figured out the cause, you will need to determine the best course of action for addressing the damage.
It is best to do all repairs from the top of the roof, which means you will have to tear up shingles and other coverings, as well as the roof decking in some cases. This may not be possible if you notice the sagging roof in the winter when snow is likely to fall, which means you will have to perform the repairs from underneath the roof in the attic. This can be difficult and dangerous, and if at all possible, you should avoid this. Tearing up the shingles and decking can be more costly, but it is safer and more efficient.
The specific repairs you will have to perform will vary depending on what type of damage the roof has incurred. A broken rafter can be especially difficult to repair, especially from underneath the roof; returning the two broken rafter pieces to the original position can be done using an L-bracket, but jacks may be necessary to lift the pieces until they are flush. The rafter can also be replaced entirely, but this is a much more significant repair that may involve the removal of significant portions of the roof decking and shingles.
If the sagging roof is due to rotting or warping roof decking, the repair will be much easier. You will need to remove the shingles and the old decking, however, which means there will be an exposed hole in the roof. This may be problematic in winter months, but allowing the roof to continue to sag can lead to greater problems such as a cave-in. The decking will need to be removed from the top of the roof, since the shingles will have to be removed and then replaced. If the decking needs to be reinforced, new lumber can be added beneath the decking rather than replacing older supports entirely.