A typical backup application follows this algorithm:
A typical back-in-time disaster recovery or file-based restore follows this algorithm:
Backing Up Virtual Disks in vSphere presents these algorithms in more detail and includes code samples. For best practices in backup and restore, see Tips and Best Practices.