You can back up messages on an iPhone to your iCloud account, or sync messages from your iPhone to your Mac.
Backing up your Mac might not always be a priority – although it should be – and it's easier than you think with Time Machine and iCloud.