How to install OS using Time Machine backup after hard drive upgrade? I'm looking to upgrade a 120GB SSD in my late 2009 iMac (21.5in) to a 250GB SSD. My mac is running the latest version of MacOS. 

I have an external USB drive which I will be setting up to create a Time Machine backup. My understanding is that once the backup has completed, I swap my internal SSD with the new SSD. Then, with keeping the USB Drive with Time Machine backup on it connected, I boot to it and some sort of Disk Utility software will walk me through restoring the Time Machine backup to my newly installed drive.

This is all good, but I have read mixed information about whether or not the Time Machine backup includes a complete backup of data and OS or if I will need to install the OS onto the new drive and update it before restoring from the Time Machine.

I don't have a physical copy of the OS, so it concerns me a little. It's a second-hand Mac and came with El Capitan installed.

Does a Time Machine backup contain the OS as well so it's as simple as boot to a Disk Utility and tell it to restore from Time Machine to the new SSD?

My first Mac, so thanks for any help!
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).