Make backups of the lock database after a cf-agent run.

This is in anticipation of turning on NOSYNC for the lock database, in
order to improve performance. But this leaves the database open to
corruption in case of system crash. To deal with that, while still
maintaining performance, we make a complete backup of the database
file at the end of an agent run, which is fsync'ed to disk in order to
survive a crash.

Later, if we detect that the database timestamp is older than the boot
time, we assume that there has been a crash, and restore the database
from the backup to avoid potential corruption.
Implement fsync() and GetUptimeSeconds() on Windows.
Merge pull request #1416 from kacfengine/lock_db_backup

Make backups of the lock database after a cf-agent run.