-
Notifications
You must be signed in to change notification settings - Fork 0
/
mongodump_example.py
58 lines (39 loc) · 1.02 KB
/
mongodump_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from core import MongoDump
"""
Use the parameters according to your need;
"""
mongodump = MongoDump(
# host='<host>',
# port=27017,
# username='<username>',
# password='<password>',
# db='<db>',
# authenticationDatabase='<authenticationDatabase>'
)
"""
Perform dump/backup;
"""
success, backup_path = mongodump.dump()
print(success, backup_path)
"""
If you want, Compress the backup;
"""
success, compressed_backup_path = mongodump.compress_backup(
backup_path=backup_path
)
print(success, compressed_backup_path)
# [============================ Under development ============================]
# """
# If desired, send compressed backup to google drive;
# """
# success = mongodump.send_backup_to_google_drive(
# compressed_backup_path=compressed_backup_path
# )
# print(success)
# """
# If you want, Decompress the backup;
# """
# success, uncompressed_backup_path = mongodump.decompress_backup(
# compressed_backup_path=compressed_backup_path
# )
# print(success, compressed_backup_path)