Setting up an automatic camera system
Typically an IP camera.

Features though vary quite a bit between brands.

Some do have the capability to record to a NAS and/or file server. You would need something like this ideally for what you want.

A fairly cheap option is edge recording, such as built in SD cards typically. Not all cameras have this and the biggest issue is theft of the camera results in loss of footage. It is usually though one of the most cost effective ways of recording.

The next solution is recording to a DVR or VMS system, there are some cheap and free options that may work on your PC. 

In terms of actual recording, you can have it on motion detection. Another option can be a reed switch or other door contact that triggers recording. These can be wired to a camera that has I/O, not all do, or quite often a DVR/VMS has this capability.

What you want is definitely achievable, just comes down to budget. There are quite a few ways to do this.