How to back up Boot Camp before upgrading my hard drive to an SSD?
Here's what I would do (haven't done it step by step, but I have fairly lot experience with swapping drives, making copies of partitions etc.):

Ensure you have the necessary parts and tools. You’ll need an external USB enclosure to copy between the old and new drives, plus a couple of different screwdrivers. For a 2012 MacBook Pro, see these instructions.

Exchange the drives (put the SSD inside)

Place your old drive in the external USB enclosure

First test: power on with the Alt key pressed when it chimes, select the external OSX and see if you can boot OS X from the external drive (this should work).
Note: you will not be able to boot your old Windows from the USB drive (booting Windows from USB is difficult/impossible and not covered here).

Boot into recovery mode. Access this by holding Command+R when turning on the machine until Apple logo appears.

Using Disk Utility, format your new drive. You may need to click View &gt; Show All Devices to get the right drive/partition to show. Be sure to choose APFS for the file system if possible—this has much better support and performance for SSDs.

Install a fresh copy of OS X on the SSD.

Ideally you should aim to install High Sierra or later which has support for Apple’s APFS file system—this has improved support for SSDs—although if you have an older Mac, consider whether it has the power to run a newer OS.
Even though you have a copy of OS X on your old drive, it appears you need an internet connection for this to occur. It may require a download of 5-10GB, so be prepared for this.
If your clock got reset when you were installing the SSD, you may get an error when attempting the OS X installation. In this case, you can try opening a terminal window and typing ntpdate -u time.apple.com which will sync your machine to the correct time over the internet.
Allow 30-90mins for the setup files to download, then another 30ish mins to install.

If you have a time machine backup you can alternatively restore that through the installer (in which case you can skip some of the installation process and the copying/migration-assistant step below) but you might not get the benefits of upgrading to APFS if your previous OS X used the HFS+ file system.

Now boot OS X from the internal SSD drive. It may ask you if you’d like to migrate all your apps and documents from your old drive, and you can generally choose “Yes”. Apple’s Migration tool is very robust and effective. A recent migration of mine took 2 hours for about 135GB of data.

Once you’re successfully booting OS X, eject and disconnect the USB drive to make sure bootcamp or Windows will not mess with it.

Run Bootcamp Assistant to make a suitably sized partition for Windows—at least 100GB is recommended. Note that Bootcamp Assistant will only work on an internal drive where your OS X install is the only single partition (plus recovery partition from the install).


You can optionally proceed with making a clean Windows install if you’d like to start fresh, or simply just to check that it boots OK. Otherwise continue with the cloning process below.
The point of the above is to create a partition layout on the SSD that both MacOS and Windows recognize.  The central thing there is, that bootcamp assitant will only let you do this from an original OS X partition layout.
Now you should have an SSD with a fresh OS X and a partition for Windows.  Your other drive is still in the original state, so you can always put it back.
If you find that you are missing any apps or functionality from your previous OS X (this should be quite rare), then you can clone your OS X by booting from the external OS X again, then use SuperDuper (or a similar tool) to copy your current OS X to the SSD.  But in general, it’s best to boot the fresh OS X from the SSD and use the Migration Assistant and copy your setup from the external drive.
To clone your Windows partition from old to new drive:
For less-technical folks, consider using WinClone, which performs many of the following steps with less trouble (it could save you a couple hours, potentially), but it costs US$39.99.
Here’s how to do it with free software:

Download a copy of gparted. You can either get a copy that can be made into a bootable USB stick (recommended), or choose a i486 ISO and burn it on a CD.   This is a graphical tool which lets you modify/clone/resize partitions.

Boot from your newly created USB or CD (you can generally choose all the default menu options as it’s booting up) and run gparted.

Be very sure to identify which drive is your old and which is your new before proceeding. If you copy in the wrong direction you will permanently lose data.

Copy the old (external) Windows partition to the internal one. Select your external Windows partition, choose copy, then select SSD Windows partition, and choose paste, then click apply. This will perform a clone of the partition, copying only the parts of the partition containing data (it’s smart enough not to copy the empty space) and it will also automatically resize it to fit the size you specified in the Bootcamp Assistant earlier. This might take 30-60mins.
Something about using gparted or resizing the partition can cause issues with booting so if you cannot restart into Windows at this point, you may need to follow these additional steps to repair the Windows boot record. (Note: the following steps apply to Macs prior to 2014 that used the Legacy BIOS/MBR method of booting Windows. Since 2014, most Macs use a newer GPT/UEFI method, in which case the commands below might not apply.)

Disable Apple SIP by restarting into recovery mode (hold Command+R when restarting), open Terminal, and type:
csrutil disable


Reboot into OSX, install the gdisk command line tool, and use it to regenerate the hybrid GPT+MBR boot records. The instructions can get a bit long, so I suggest you read them here. If you are also booting Linux, you may need to ensure you include your Linux partition in the list of bootable partitions during the MBR creation step. (I’m only booting OSX + Windows so I cannot test this step with Linux.)

If Windows will still not boot (at this point I was seeing a blue screen of death with an error about winload.exe), you need to repair the boot files by booting to an installation disc/USB of the Windows version you have, then choose repair Windows installation. If the automated “Start-up Repair” option doesn’t work, you can try running these commands from the Windows installer command line:
Note: first check that C:\ is actually the correct drive that you intend to perform the repair on. Otherwise replace c: in the commands below with the relevant drive letter.
bootsect /nt60 c: /mbr
attrib  -r  -h  -s  c:\boot\bcd
del c:\boot\bcd
bcdboot c:\windows /s c: /f BIOS

Source: https://apple.stackexchange.com/a/333605/30551


After all that, you should have a functioning dual booting system. Remember to hold Option when turning on to choose your OS, or choose it from within OS X System Preferences &gt; Startup Disk.