Commit 0a0a2786 authored by ajil.k's avatar ajil.k

Update translator.py

parent 28acb8fc
......@@ -9,48 +9,48 @@ from datetime import datetime, timedelta
from schema import DeviceDetails, DeviceParameters
# Set the MongoDB URL to connect to
mongo_url = 'mongodb://ilens:ilens%401234@192.168.0.220:4720/?authSource=admin'
# # Set the MongoDB URL to connect to
# mongo_url = 'mongodb://ilens:ilens%401234@192.168.0.220:4720/?authSource=admin'
# Set the path to the mongodump executable
mongodump_path = 'C:/Program Files/MongoDB/Server/6.0/bin/mongodump.exe'
# # Set the path to the mongodump executable
# mongodump_path = 'C:/Program Files/MongoDB/Server/6.0/bin/mongodump.exe'
# Set the name of the database to be dumped
db_name = 'Iot_manager(Test)'
# # Set the name of the database to be dumped
# db_name = 'Iot_manager(Test)'
# Set the path where the dump will be saved
dump_path = 'E:/Iot_manager(Test)/dumped_data'
# # Set the path where the dump will be saved
# dump_path = 'E:/Iot_manager(Test)/dumped_data'
# Build the command to be executed
command = [mongodump_path, '--uri', mongo_url, '--db', db_name, '--out', dump_path]
# # Build the command to be executed
# command = [mongodump_path, '--uri', mongo_url, '--db', db_name, '--out', dump_path]
# Execute the command
subprocess.call(command)
# # Execute the command
# subprocess.call(command)
# mongo restore
# # mongo restore
mongorestore_path = 'C:/Program Files/MongoDB/Server/6.0/bin/mongorestore.exe'
now = datetime.now()
# mongorestore_path = 'C:/Program Files/MongoDB/Server/6.0/bin/mongorestore.exe'
# now = datetime.now()
date_str = now.strftime("%Y-%m-%d")
# date_str = now.strftime("%Y-%m-%d")
new_db_name = f"Iot_manager(Test)_copy_{date_str}"
# new_db_name = f"Iot_manager(Test)_copy_{date_str}"
restore_command = [mongorestore_path, '--uri', mongo_url, '--db', new_db_name, dump_path + "/" + db_name]
subprocess.call(restore_command)
# restore_command = [mongorestore_path, '--uri', mongo_url, '--db', new_db_name, dump_path + "/" + db_name]
# subprocess.call(restore_command)
def zip_folder(folder_path, zip_path):
with zipfile.ZipFile(zip_path, 'w', compression=zipfile.ZIP_DEFLATED) as zip:
for root, dirs, files in os.walk(folder_path):
for file in files:
file_path = os.path.join(root, file)
zip.write(file_path, file_path[len(folder_path):])
# def zip_folder(folder_path, zip_path):
# with zipfile.ZipFile(zip_path, 'w', compression=zipfile.ZIP_DEFLATED) as zip:
# for root, dirs, files in os.walk(folder_path):
# for file in files:
# file_path = os.path.join(root, file)
# zip.write(file_path, file_path[len(folder_path):])
zip_folder(dump_path, 'E:/Iot_manager(Test)/dumped_data.zip')
# zip_folder(dump_path, 'E:/Iot_manager(Test)/dumped_data.zip')
""" end of mongo dumping and backup"""
# """ end of mongo dumping and backup"""
""" mongo migration"""
# set up the connection to MongoDB
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment