Safari lost half my extensions and passwords after a system crash The crash was logged into console
and it caused logout from my system.
After I've logged in again Safari lost most of my passwords and extensions.

I've already looked at this and it didn't help.

I'm using iCloud Keychain and I've checked on my phone - the passwords are still there. I also looked into ~/Library/Safari/Extensions/ and all my extensions are still there, just not visible in safari preferences.

I've tried using Time Machine on ~/Library/Safari/ but it also didn't work.

I have to say that this is very annoying since it happened to me at least 3 times in past 2 years.

1) What can I do to restore all my iCloud passwords? 

2) What can I do to restore all my Safari extensions without installing them again one-by-one?

3) What can I do to stop this from occurring again?

I guess 3) is too much to ask for, but I need at least a reliable procedure that can restore everything to the state it was before.
I'm also not the only person affected by this problem - my cousin turned to 1-Password exactly because of this behaviour.
As you may have noticed from my question, I was very determined to find a solution and finally I found one. If you have a Time Machine setup then you're lucky. All you need to do is to restore those 4 folders (remember to select all the contents from the backup) to the time before the crash.

~/Library/Safari/Extensions/

~/Library/Keychains

/Library/Keychains

/System/Library/Keychains

(Probably not all are needed, but this worked for me)

Restart and open safari to check that everything is on place. Re-enable Keychain if it was disabled (mine was enabled, but turned to disabled in this process). Enjoy.