check if 'sync' method exists before calling it

It turns out that anydbm does not have a public sync() method, per the docs: https://docs.python.org/2/library/anydbm.html
On ubuntu, there is one, but on OS X, there isn't, so adding a check to see if actually exists before calling it.
Found in ikreymer/pywb-webrecorder#4