Skip to content

Instantly share code, notes, and snippets.

@lanbugs
Created June 27, 2018 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lanbugs/e40712b37d51c91ef01f8234c7467c8b to your computer and use it in GitHub Desktop.
Save lanbugs/e40712b37d51c91ef01f8234c7467c8b to your computer and use it in GitHub Desktop.
Backup Cisco configuration by write event to external server - Example for Flask
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# write config to file with cisco archive command
# see more in blog article: https://lanbugs.de/netzwerktechnik/hersteller/cisco/cisco-python-backup-der-konfiguration-bei-write-event-auf-externen-server/
from flask import Flask
from flask import request
app = Flask(__name__)
@app.route("/put/<cfg>", methods=['PUT'])
def get_config(cfg):
with open('/opt/cisco_config/incoming_configs/%s' % cfg, "wb") as f:
f.write(request.data)
return "ok"
if __name__ == "__main__":
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment