Lion - Time Machine issues with an old NAS

Anyone who's using Lion with Time Machine and has an old NAS as a backup destination will have come across the issue with AFP using a new authentication protocol which probably isn't supported by the NAS.

(I have a not so old Buffalo Linkstation (LS-CH1.OLT) that still didn't work after updating to the latest firmware)

Anyway, I spent ages trying to get it to work until I came across this script which I'm re-posting as it was hard to find:

Basically, it hacks Lion to trick the new protocol into communicating with your old NAS.

More importantly, unlike the other workarounds I works!