
Using AI to Automate Cisco IOS XR Backups
Imagine using AI and your natural language to create an automated system to back up Cisco network device configurations daily.
The Challenge: Daily Configuration Backups
The Power of Natural Language for Network Automation
How Our Conversation Guided the Development
Documentation and Visualization
The Technical Solution Behind My Natural Language Prompts
Code Structure Through Natural Language
Technical Insights Without Technical Specifications
Benefits of Natural Language Network Automation
Reflections on Natural Language Programming
- Connect to a Cisco router using SSH
- Retrieve the complete running configuration
- Save it with timestamps for version tracking
- Run automatically on a daily schedule

Ok lets create a script using python and nornir to get the Cisco device's running-config and schedule this to run daily.
- Use Python as the programming language
- Leverage the Nornir framework for network automation
- Retrieve running configurations from network devices
- Create a scheduling mechanism for daily execution
lets set this up in a venv
- no need to remember virtual environment commands or syntax. - Created a Python virtual environment
- Activated it
- Installed all necessary dependencies (nornir, nornir-netmiko, nornir-utils, python-dotenv)
its in /Documents/temp
. No need to provide exact file paths or explain file formats - Amazon Q understood the context and located the necessary files.ok lets run this to see it works
. - Executed the script
- Connected to the Cisco device
- Retrieved the configuration
- Saved it with a timestamp
- Showed me the results
write a blog about what we just did. How we were able to work together to create this solution.
Please add to the blog a mermaid diagram show the code structure. Also add one showing the flow from device to Cisco.
- Handling pagination issues specific to Cisco IOS-XR devices
- Creating timestamped filenames for version tracking
- Proper error handling and exit codes
- Loading credentials securely from environment variables

- Pagination Handling: When retrieving configurations from Cisco devices, pagination can truncate output. Amazon Q automatically included code to disable pagination with "terminal length 0" - something I never explicitly mentioned.
- Platform-Specific Logic: The code includes conditional logic for IOS-XR devices, showing an understanding of platform differences.
- Secure Credential Management: Amazon Q implemented proper credential handling using environment variables rather than hardcoding them.
- Error Handling: The script includes proper error detection and exit codes for automation reliability.
- Reduced Knowledge Barriers: You don't need to be an expert in Python, Nornir, or cron scheduling to create sophisticated automation.
- Faster Implementation: I went from concept to working solution in minutes, not hours or days.
- Focus on Intent: I could focus on what I wanted to accomplish rather than how to implement it.
- Built-in Best Practices: Amazon Q incorporated technical best practices I might have overlooked.
- Adaptability: When requirements changed or issues arose, I could express the changes in natural language.
- Searching for the right libraries and commands
- Writing boilerplate code
- Debugging syntax errors
- Figuring out scheduling syntax
The most impressive part was how Amazon Q Developer CLI understood networking concepts like pagination in Cisco devices and implemented appropriate solutions without me having to specify them. When I said
Ok lets create a script using python and nornir to get the Cisco device's running-config and schedule this to run daily
, Amazon Q knew exactly what libraries to use, how to structure the code, and how to handle device-specific requirements.- Natural Language as a Primary Interface: Instead of CLI commands or programming languages, natural language could become the primary interface for network automation.
- Focus on Architecture and Requirements: Engineers can focus more on the "what" and "why" rather than the "how."
- Reduced Learning Curve: New engineers might need less time to become productive, as they can leverage AI to handle implementation details.
- Democratized Automation: Network automation becomes accessible to those without strong programming backgrounds.
PS: This post was mostly written by Amazon Q Developer CLI after we performed the automation tasks above.
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.