[backend] Change FileLock to be atomic using symlinks, and work as a context manager to ensure that the lock is removed also on exceptions