Fixing a wood barrier
One fix is to go to the big box store and buy some short lengths of re-bar (the stuff normally used to reinforce concrete). You can get it in lengths like 2' or 3' or 4'.

The idea is to get the old timbers lined up as much a possible. That may mean having to dig away on one side if dirt has come down behind where you want to push the timber. Once you have things lined up you want to drill a hole in the center of the beam(s) from the top down trough. Then pound the re-bar trough the hole and down into the ground using a heavy maul or hammer. Sink the top end of the re-bar right down to the timber top so it is not sticking out. This will hold the timbers in alignment and in place due to the re-bar going down into the ground.

For best results you would want to keep the hole diameter only slightly larger than the re-bar. It does take a long drill bit to go through two or three timbers at once but you can find them. Look for the 4 or 5 foot flexible type that wiring installers use to drill holes inside walls.