Mongodb backup using python

import os folder = "back folder path(Mongdb backup file contains bson and json files" results = [each for each in os.listdir(folder) if each.endswith('.bson')] for bsonfiles in results: command = "mongorestore --db <<DATABASE NAME>>" + " " + folder + "/" + bsonfiles os.system(command)
Mongodb backup from the dumped files(json or bson).

do the follows : take the backup data from the mongodb and locate the folder in the program , put the name of the database with out "<<>>"

sample :
folder = "/home/backup/mongo/"
command = "mongorestore --db sampledb" + " " + folder + "/" + bsonfiles

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.