These 2 are definitely not interchangeable in all situations. When you use "but" instead of "only", it may sound fancier - like in your example. You COULD exchange them also in a more casual sentence like this one: "I would go to the game, but/only I have a lot of homework." I guess they can be interchangeable when they are used to explain an exception to a rule, but "but" should never be before the verb - like "I only have one life." You couldn't use "but" here. I hope this helps, this is a good question!