use a pymongo bulk upsert operation to prevent data loss

I found that when doing a delete and insert sometimes the insert would fail and I would loose retention data if a scheduler was restarting.