Can I get an unlocked phone instead of upgrading?

I currently have an iPhone 6 to go along with my AT&T wireless plan. For reason I don't need to get into, I'd rather not upgrade my phone through AT&T. My question is, can I just go into Best Buy or online and buy an unlocked iPhone X (for example) and just put my iPhone 6 SIM card into the new phone, then use a backup saved on my computer? Will this transfer service and everything onto the new phone without any issues?