I stumbled upon this problem several times and tried to troubleshoot it here. I was just also going through Bug: Losing Changes in Macros
Somewhat by accident, I discovered a way to recover the macros. This works for iCloud, not sure about other service providers.
Navigate to your iCloud .kmsync file location
Double click it. This should open a pop up window notifying you about a sync conflict, prompting you for a resolution
Tick checkboxes for the last few snapshots (in my case, I narrowed it to 2, several hours apart).
Save these files
Go to Keyboard Maestro's General Preferences, uncheck and check again Sync Macros
Load the file of choice (if you're not sure which one, make an educated guess based on the edit time and file size – you can always repeat steps 5–6 with another file)
In my case, I was fortunate enough to recover a dozen of my macros that I've created yesterday.
Just to let you know, for some reason double clicking any of the recovered .kmsync files directly won't load them to Keyboard Maestro, it has to be done via the Sync Macros checkbox route.
Option 2: Don’t use iCloud... Nah but all jokes aside, thanks for this info. I know a number of users do use iCloud for library syncing, so no doubt they’ll benefit from this.
Yeah I've actually just moved my kmsync file to the Shared folder (as I need it for two local macOS user profiles, so it's good for me) and I'm coding a backup iCloud sync with Automator that monitors the changes in the Shared/KM folder
Could you please describe your approach to monitor the Shared/KM folder?
Does it mean any changes to the shared folder's content (= the sync file) will duplicate the sync file to an iCloud folder, replacing the one already there and from that file KM on the second Mac will sync?
I’m having exactly this issue. I have some lengthy sets of macros, for example a list of locations to label photos in Photos.app. I laboriously modified my whole list recently, and come to find that all the modifications are lost.
I use iCloud for syncing, but lately I’m only really using one of my Macs most of the time and the secondary Mac is shut down. Is the problem that when I start the secondary Mac KM syncs from an old sync file, overwriting my new one? Is there a way to specify that sync only works in one direction? I could live without syncing, but it has worked for many years.
I followed the instructions above, but when I get to step 6 I get into an endless loop of a dialog box that says Modifications aren’t in sync. Choose which versions to keep. I choose one and click Keep and the dialog reappears.
Update:
Though the problem I described above persists, at some point I did recover the large modified list of text macros.