It seems to work, but i'm still waiting for the first run-through.

Downloading messages: 457 of 22831|

This takes ages. I hope it doesn't try to re-download all my messages everytime.

Nope. It's very smart about not doing that.
 

Another thing:
It seems that throughout its run, your script locks the notmuch database. This is particularly
annoying if you want to read/tag mails while waiting for a long sync-process. I think you only
really want to lock the index for a short time in the end.
Do you write to the index directly after a msg is downloaded?

I tried to solve this by closing and opening the database each time, but it actually reduced the performance considerably -- even slower than the gmail download.