-
Notifications
You must be signed in to change notification settings - Fork 16
/
restore
executable file
·47 lines (38 loc) · 1.28 KB
/
restore
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
#!/usr/bin/env python
import os
import argparse
import requests
from mist.api import config
from mist.api.portal.tasks import restore_backup
def main():
portal_host = config.PORTAL_URI.split('//')[1]
argparser = argparse.ArgumentParser(
description="Restore a Mist backup"
)
argparser.add_argument('backup', help="Backup to restore.")
argparser.add_argument('--db', help="Database backups to restore.")
argparser.add_argument('--until',
help="Keep restoring previous backups until",
default=False)
argparser.add_argument('--portal', help="Portal nane.",
default=portal_host)
args = argparser.parse_args()
if args.backup.startswith('s3://'):
# TODO
return
if not args.db:
dbs = ['mongo', 'influx', 'victoria', 'vault']
else:
dbs = []
if 'mongo' in args.db:
dbs.append('mongo')
if 'influx' in args.db:
dbs.append('influx')
if 'victoria' in args.db:
dbs.append('victoria')
if 'vault' in args.db:
dbs.append('vault')
return restore_backup(
args.backup, portal=args.portal, until=args.until, databases=dbs)
if __name__ == '__main__':
main()