How to install OS using Time Machine backup after hard drive upgrade?

If you haven‘t defined any exclusions in the Time Machine options then your backup drive will contain a full backup including system, apps, and user data.

To restore, you connect the backup drive to your Mac and press cmd-R when starting up. This will start from the Recovery system invisibly contained on the Time Machine disk. You’ll see an assistant window from which you select the first item, “Restore From Time Machine Backup“. Then you can select which of the saved backups you want to restore.

It’s as easy as that. But please make sure you use this mechanism only to restore a system onto the very same Mac you made the backup of. Don’t use it to restore a backup onto a different machine type as it could break your system if build versions don’t match hardware requirements. Should you want to restore a backup onto another system, Apple recommends you to use Migration Assistant (in /Applications/Utilities).