“Is there some way to keep previous versions of Power Automate flows, a chance of restoring a backup if something goes wrong?”
When you’re designing a Power Automate flow, you’re working with the only version of the flow that exists. Whatever you do, it stays in there. Except the small ‘Undo’ button, there’s no way to revert any changes.
That can be problematic. What if you, or somebody else, do changes that break the flow? How do you retrospectively see what was changed? How do you go back to the previous version of the flow?
Create your own backups
Even though there’s no flow versioning, you can add a similar functionality by yourself. You can create a scheduled flow that’ll run on regular basis and ‘backup’ all the flows.
Note: by ‘backup’ I mean exporting the flow JSON definition.
Firstly, list your flows on an environment with the ‘List My Flows’ action from the Power Automate Management group. It’ll give you some basic information like the flow id (called Flow Name), flow name (called Flow Display Name), etc.
Once you have all the flows basic information, get the whole flows one by one using ‘Get Flow’ and their id (called Flow Name).
Take the whole result and store it in a JSON file, e.g. in a SharePoint document library. This will be your backup.
How to use this backup
As already noted, the backup is a JSON definition of the flow. It’s not something you can take and restore by pressing a button, but you can use it to find the changes. Any code editor, e.g. Visual Studio Code, will reformat the output as a JSON, making it easier to read and understand. It’ll also allow you to compare an older file with a newer one, highlighting the differences.
The part you’re most interested in is the “actions”, with all the flow action definitions. If there’re differences, there was probably some change in the flow. I’m adding ‘probably’ because sometimes it’s just a different line order.
The property names are quite understandable so it shouldn’t be a big issue to understand what changed.
Once you identify the changes, you can go back to the live flow in the designer and adjust it accordingly. If it’s just a difference in an expression, you can easily replace it. If it’s a whole set actions missing it’ll be a bit more work though.
Update: there’s now also an article explaining how to restore a flow from such backup.
Power Automate has some potentially interesting actions in the Power Automate Management group, allowing you to restore deleted flows, backup flows, and probably many more. This article explains quite a basic way of a flow backup, it still needs you to understand the JSON structure and all recoveries are done manually, but it’s still better than having no backup at all. And I feel there might be a possibility that such JSON export could be used to create or update a flow later…