diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index f9b6ed7d85b..a37e72f6221 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -1087,21 +1087,20 @@ async def backup(self, ctx: commands.Context, backup_path: str = None): if basic_config["STORAGE_TYPE"] == "MongoDB": from redbot.core.drivers.red_mongo import Mongo - m = Mongo("Core", **basic_config["STORAGE_DETAILS"]) + m = Mongo("Core", "0", **basic_config["STORAGE_DETAILS"]) db = m.db - collection_names = await db.collection_names(include_system_collections=False) + collection_names = await db.list_collection_names() for c_name in collection_names: if c_name == "Core": c_data_path = data_dir / basic_config["CORE_PATH_APPEND"] else: - c_data_path = data_dir / basic_config["COG_PATH_APPEND"] - output = {} + c_data_path = data_dir / basic_config["COG_PATH_APPEND"] / c_name docs = await db[c_name].find().to_list(None) for item in docs: item_id = str(item.pop("_id")) - output[item_id] = item - target = JSON(c_name, data_path_override=c_data_path) - await target.jsonIO._threadsafe_save_json(output) + output = item + target = JSON(c_name, item_id, data_path_override=c_data_path) + await target.jsonIO._threadsafe_save_json(output) backup_filename = "redv3-{}-{}.tar.gz".format( instance_name, ctx.message.created_at.strftime("%Y-%m-%d %H-%M-%S") )