Whenever I get off track several things help:
1. For ME
its difficult if I've been out of the swing of things to go completely back to eating and exercising perfectly so I try to make weekly goals to get me back on track. Starting with something small and doable(like planing meals for the week, exercising 15 min a day act) builds up my confidence and makes me feel like getting back on track is possible. Others might have success with tossing everything away and getting 100% back on plan in one go, but idk doesn't seem to work for me. Too much pressure and then when I ultimately fail because its too much to deal with I will go back into a spiral of poor eating choices.
2. Logging in here everyday. Whenever I'm doing poorly this really helps.
3. Logging all calories even if I'm off plan. For me, its easy to ignore the damage if I don't log the calories. I force myself to log the calories no matter what and that makes it more real and forces me to be aware.
4. Daily weighing. This is a tricky one and for some people it really messes with their heads which is why its important to really pick and choose which works best for YOU. For me, daily weighing is really useful and I have a chart to log my fluctuations and have one official weigh in day. When I stop weighing, the damage seems less real. I am always at least a little better with my choices when weighing daily.
5. Joining a challenge. Challenges are very helpful to me on here. I don't have anyone in real life who's interested in being healthy or supporting me so I find support and motivation from people on this site
Best of luck