MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / backup

Function backup

app/deploy/redis_backup_service/backup_server.py:13–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11
12@app.route("/backup", methods=["POST"])
13def backup():
14 try:
15 subprocess.run(["redis-cli", "save"], check=True)
16
17 rdb_path = "/data/dump.rdb"
18 timestamp = datetime.utcnow().strftime("%Y%m%d-%H%M%S")
19 gzip_path = f"/tmp/dump-{timestamp}.rdb.gz"
20 s3_key = f"redis-backups/dump-{timestamp}.rdb.gz"
21
22 with open(rdb_path, "rb") as f_in, gzip.open(gzip_path, "wb") as f_out:
23 f_out.writelines(f_in)
24
25 s3 = boto3.client(
26 "s3",
27 endpoint_url=os.environ["S3_ENDPOINT"],
28 aws_access_key_id=os.environ["S3_ACCESS_KEY_ID"],
29 aws_secret_access_key=os.environ["S3_SECRET_ACCESS_KEY"],
30 )
31
32 s3.upload_file(gzip_path, os.environ["S3_BUCKET"], s3_key)
33
34 os.remove(gzip_path)
35
36 return jsonify({"status": "ok", "uploaded": s3_key})
37
38 except Exception as e:
39 return jsonify({"status": "error", "error": str(e)}), 500
40
41
42if __name__ == "__main__":

Callers

nothing calls this directly

Calls 2

clientMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…