Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iot_manager_migration
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ajil.k
iot_manager_migration
Commits
0a0a2786
Commit
0a0a2786
authored
May 05, 2023
by
ajil.k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update translator.py
parent
28acb8fc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
27 deletions
+27
-27
translator.py
translator.py
+27
-27
No files found.
translator.py
View file @
0a0a2786
...
@@ -9,48 +9,48 @@ from datetime import datetime, timedelta
...
@@ -9,48 +9,48 @@ from datetime import datetime, timedelta
from
schema
import
DeviceDetails
,
DeviceParameters
from
schema
import
DeviceDetails
,
DeviceParameters
# Set the MongoDB URL to connect to
#
#
Set the MongoDB URL to connect to
mongo_url
=
'mongodb://ilens:ilens
%401234
@192.168.0.220:4720/?authSource=admin'
#
mongo_url = 'mongodb://ilens:ilens%401234@192.168.0.220:4720/?authSource=admin'
# Set the path to the mongodump executable
#
#
Set the path to the mongodump executable
mongodump_path
=
'C:/Program Files/MongoDB/Server/6.0/bin/mongodump.exe'
#
mongodump_path = 'C:/Program Files/MongoDB/Server/6.0/bin/mongodump.exe'
# Set the name of the database to be dumped
#
#
Set the name of the database to be dumped
db_name
=
'Iot_manager(Test)'
#
db_name = 'Iot_manager(Test)'
# Set the path where the dump will be saved
#
#
Set the path where the dump will be saved
dump_path
=
'E:/Iot_manager(Test)/dumped_data'
#
dump_path = 'E:/Iot_manager(Test)/dumped_data'
# Build the command to be executed
#
#
Build the command to be executed
command
=
[
mongodump_path
,
'--uri'
,
mongo_url
,
'--db'
,
db_name
,
'--out'
,
dump_path
]
#
command = [mongodump_path, '--uri', mongo_url, '--db', db_name, '--out', dump_path]
# Execute the command
#
#
Execute the command
subprocess
.
call
(
command
)
#
subprocess.call(command)
# mongo restore
#
#
mongo restore
mongorestore_path
=
'C:/Program Files/MongoDB/Server/6.0/bin/mongorestore.exe'
#
mongorestore_path = 'C:/Program Files/MongoDB/Server/6.0/bin/mongorestore.exe'
now
=
datetime
.
now
()
#
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
]
#
restore_command = [mongorestore_path, '--uri', mongo_url, '--db', new_db_name, dump_path + "/" + db_name]
subprocess
.
call
(
restore_command
)
#
subprocess.call(restore_command)
def
zip_folder
(
folder_path
,
zip_path
):
#
def zip_folder(folder_path, zip_path):
with
zipfile
.
ZipFile
(
zip_path
,
'w'
,
compression
=
zipfile
.
ZIP_DEFLATED
)
as
zip
:
#
with zipfile.ZipFile(zip_path, 'w', compression=zipfile.ZIP_DEFLATED) as zip:
for
root
,
dirs
,
files
in
os
.
walk
(
folder_path
):
#
for root, dirs, files in os.walk(folder_path):
for
file
in
files
:
#
for file in files:
file_path
=
os
.
path
.
join
(
root
,
file
)
#
file_path = os.path.join(root, file)
zip
.
write
(
file_path
,
file_path
[
len
(
folder_path
):])
#
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"""
""" mongo migration"""
# set up the connection to MongoDB
# set up the connection to MongoDB
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment