assert authenticated, 'Could not authenticate to database!'
collections = database.collection_names()
for i, collection_name in enumerate(collections):
    col = getattr(database, collections[i])
collection = col.find()
jsonpath = collection_name + '.json'
jsonpath = join(backup_db_dir, jsonpath)
with open(jsonpath, 'wb') as jsonfile:
    jsonfile.write(dumps(collection))
PyMongo/Mongoengine эквивалент mongodump