This commit is contained in:
parent
54dba98af2
commit
61f8f0f95f
15
backup.py
15
backup.py
@ -33,7 +33,7 @@ def generate_targets():
|
||||
i.metadata.name,
|
||||
"innodbclusters")
|
||||
for target in targets["items"]:
|
||||
yield i.metadata.name, "innodbclusters", "-", target["metadata"]["name"]
|
||||
yield "innodbclusters", i.metadata.name, "-", target["metadata"]["name"]
|
||||
|
||||
# Handle MongoDB community operator
|
||||
targets = api_instance.list_namespaced_custom_object(
|
||||
@ -44,8 +44,9 @@ def generate_targets():
|
||||
for target in targets["items"]:
|
||||
for user in target["spec"]["users"]:
|
||||
for role in user["roles"]:
|
||||
yield i.metadata.name, "mongodbcommunity", \
|
||||
yield "mongodbcommunity", i.metadata.name, \
|
||||
user["name"], role["db"]
|
||||
break
|
||||
|
||||
|
||||
@app.route("/cronjob.sh")
|
||||
@ -61,8 +62,8 @@ def generate_script():
|
||||
return app.response_class(generate(), mimetype="text/plain")
|
||||
|
||||
|
||||
@app.route("/stream/<namespace>/innodbclusters/<user>/<database>")
|
||||
def innodbclusters_stream(namespace, user, database):
|
||||
@app.route("/stream/innodbclusters/<namespace>/<user>/<database>")
|
||||
def stream_innodbclusters(namespace, user, database):
|
||||
if request.headers.get("Authorization") != TOKEN:
|
||||
raise
|
||||
with ApiClient() as api:
|
||||
@ -83,8 +84,8 @@ def innodbclusters_stream(namespace, user, database):
|
||||
download_name="%s_%s.sql.gz" % (namespace, database))
|
||||
|
||||
|
||||
@app.route("/stream/<namespace>/mongodbcommunity/<user>/<database>")
|
||||
def mongodbcommunity_stream(namespace, user, database):
|
||||
@app.route("/stream/mongodbcommunity/<namespace>/<user>/<database>")
|
||||
def stream_mongodbcommunity(namespace, user, database):
|
||||
if request.headers.get("Authorization") != TOKEN:
|
||||
raise
|
||||
with ApiClient() as api:
|
||||
@ -98,7 +99,7 @@ def mongodbcommunity_stream(namespace, user, database):
|
||||
return send_file(process.stdout,
|
||||
mimetype="application/tar+gzip",
|
||||
as_attachment=True,
|
||||
download_name="%s_%s.tar.gz" % (namespace, database))
|
||||
download_name="%s_%s.gz" % (namespace, database))
|
||||
|
||||
|
||||
app.run(host="0.0.0.0", debug=False, threaded=True)
|
||||
|
Loading…
Reference in New Issue
Block a user