Better error handing for duplicating documents

When duplicating a large group of documents some may fail, catch the failures and send an email per-failure with the bad
document id for investigation.

Also wrap the duplication inside a transaction so that a document doesn't end up half-copied.