How can I keep my Mac awake AND locked? I want to leave my Mac awake overnight so it syncs 4GB of data from Dropbox. I need to prevent the machine from going to sleep because that pauses the Dropbox sync

I've been using Caffeine to keep the computer awake, but it also keeps the computer unlocked which is insecure.

I need a method to keep my Mac awake (so that Dropbox can sync overnight) but also locked (so no one can read my email). It'd be great if this method also turned off the screen (to preserve power), but honestly that's not even 100% necessary.
In System Preferences > Energy Saver, check the box for "Prevent computer from sleeping automatically when the display is off" (on laptops, this is under the Power Adapter tab)
In System Preferences > Security &amp; Privacy, check the box for "Require password after sleep or screen saver begins" and set the delay in the dropdown menu to "immediately"


Now, you can hit command-option-power to turn off the display without sleeping the computer, and doing anything that turns on the display (like hitting a key or clicking a mouse button) will prompt you for your account password.

On newer macs without the eject key, please use control-shift+power instead.