Stopping dog from going on bed after being allowed for years?

My dogs have always been able to sleep on my bed. But I am reaching a point where I feel like I should stop doing it, mostly for hygienic reasons—he sheds a lot and stains my duvet easily.

Is there anyone who has successfully trained a dog to quit going on the bed?

The simple solution, I believe, would be to just move his own bed to a different room and make sure the door is closed. How long before they stopped going on even while the door was open and did anyone else do this? Though I would prefer not to be on or in the bed right now, I do like him sleeping in my room.

Training a dog to stay off the bed after years of being allowed can be a challenge. One thing that worked for me was gradually transitioning my dog to his own comfy bed in another room. Initially, I closed the door to discourage him from sneaking back onto my bed. It took a couple of weeks for him to get used to his new spot, but consistency is key. Now, even with the door open, he prefers his own space.