I agree with the sentiment though-- you really do need the motivation to just DO it. I get good sleep, but I do work longer hours than most people, and I've done so for years. But I genuinely have been only getting healthier and less stressed over time. Work smarter, not harder-- and I've just been getting smarter about how to handle my time.
Depends on what your goals are of course. Quality of life is a big one for me, and that puts my health high on my priorities-- I can't enjoy my riches if I'm sick and dead. But sometimes it's "I can't enjoy my health if I don't have money to eat" so I get the flip side, cause I've been there in work-til-you-drop mode out of necessity.
Most of the times I would work like this for a 2~3 weeks to a couple of months without being exhausted. But when that does happen, I would take a break for as many days I want. Normally this break never lasts over 3-4 days. (Like I said, it is important that you are working on the right thing. Otherwise you will never pull this off. For example if the main motivation for your work is you're just looking for some easy way to create a side project that will give you good enough passive income, you are probably not passionate enough about the problem and will give up. In my case I truly believed in what i was working on so it didn't make sense to just go slow on it)
As for my day job performance, it didn't really suffer because most people don't really focus 100% at work anyway.
While I was going through this lifestyle, I tried my best to stay disciplined. For example, I would start working immediately after I arrive at work, with no web browsing. And no web browsing while I am working. If you stick to this principle, you'd be amazed how much you can get done in half the time you normally spend at work. Then with the extra time I have on my hand I would take a nap etc. so I don't get too physically tired.
1. Get off work at 6 and get home at 6:30.
2. Eat something very simple (no carbs because it will make me sleepy)
3. Start working from 7:00
4. Work till 6:00am (that's 11 hours, which is 3 hours more than my day job)
5. Go to sleep at 6:00 and wake up at 10am and go to work
6. Minimize lunch time and take a nap.
This was possible because I was super motivated. If you're not excited enough about something that you would go through all this trouble, then it's probably not worth investing your time in. That's why I think you're asking the wrong question if you ask "how do you keep your energy?" You don't. You will be always tired and you will not have a balanced life while you do this. But at least you are doing something that means a lot to you, and that's the main factor that helps you keep going.
Of course it is not sustainable to keep going like this for years with no break. So you should take a break once in a while. In my case, at times I would feel very tired or start feeling like burning out. Then I would just take a couple of days off from doing ANY work. Go out and party, watch a movie, do all the "bad" things I would never normally do. I think most people who haven't tried this would say this doesn't work. But from my experience, just a couple of days of doing absolutely nothing is enough to get me back on track--that is, assuming that I am excited enough about the project to begin with.
So if this model doesn't work for you, it probably means you should find another project to work on.