def api(type): l=lib.container(options) u=lib.user(options) d=lib.domain(options) db=lib.database(options) b=lib.backup(options) a=lib.admin(options) if request.method=="GET": if type=="container": return Response(json.dumps(l.list()),mimetype="application/json") elif type=="user": return Response(json.dumps(u.list()),mimetype="application/json") elif type=="domain": return Response(json.dumps(d.list()),mimetype="application/json") elif type=="database": return Response(json.dumps(db.list()),mimetype="application/json") elif type=="backup": return Response(json.dumps(b.list()),mimetype="application/json") elif type=="admin": return Response(json.dumps(a.list()),mimetype="application/json") elif type=="images": return Response(json.dumps(l.images()),mimetype="application/json") else: return Response(json.dumps({'status':'Error','extstatus':'service not defined'}),mimetype="application/json") else: print("not implemented") return json.dumps({})
def apinamedbackup(name): b=lib.backup(options) if request.method=="DELETE": return Response(json.dumps(b.delete(name,request.form)),mimetype="application/json") elif request.method=="PUT": return Response(json.dumps(b.create(name,request.form)),mimetype="application/json") else: print(request.method+" not implemented") return json.dumps({})
import lib import yaml with open('backup.yml') as stream: config = yaml.safe_load(stream) lib.backup(config['backups_root'], config['sources'])