Backing up the Meraki Configuration
IFM supplies network engineering services for $NZ180+GST per hour. If you require assistance with designing or engineering a Cisco network - hire us!
You're about to make some changes to your Meraki configuration and you would like to make a backup first. The best approach is to clone the network (or even the whole organisation) in Dashboard. Even so, you would feel more comfortable if you could just backup the config to a file and put it on your machine.
Well this is almost your luky day. This Python script can backup (and restore) about 75% of the config. Things it can backup include: Firewall rules for MX, MR, Cellular Failover and VPN; About 99% of SSID settings for MRs; AutoVPN configuration; Non-Meraki VPN Settings; SNMP Settings; Organisation Admins and their permissions
Some of the things it can't backup include: Group Policies, Anything to do with phones or Systems Manager, anything to do with SAML, Configuration Templates and network bindings, and any client specific config
To get started you are going to need to install Python3 on your computer, and right click and download this script: meraki-backup.py (last updated 30-Dec-2019)
You are also going to need to install two Python modules:
pip install requests
pip install meraki-sdk
Next following this procedure to enable API access and get yourself an API Key. This is like a password - so protect it like such. You should make a note of it somewhere safe as you may need it again in the future.
Next you need to create a ".meraki.env" file in your home directory (special note for Windows users - the filename is dot meraki dot env). This is used to store your sensitive information. If you are a Windows user and you go Windows+R and type in "cmd" and hit return you'll have a command prompt with the current directory equal to your home directory. From here you can go "notepad .meraki.env" to create the file. A sample might look like:
Performing a backup
To perform a backup execute this command:
python3 meraki-backup.py "Org Name"
Where apicode is the code you got from the Dashboard, and "Org Name" is the actual name of the organisation you want to backup.
Performing a restore
The backup script creates another script called "meraki-restore.py". To execute it:
python3 meraki-restore.py "Org Name"Before running this script you should edit it. Note these things:
- You should delete anything from the restore script that you don't want restored.
- For the vast majority of things the restore script wont allow you to overwrite what is already configured. I did this on purpose because this script is very new, and I wanted to reduce the risk of people accidentlly damaging their Cisco Meraki environments. So if you have a network called "Production" and you want to restore it then edit the meraki-restore.py script, search for "Production" and change it to something like "Production-Restored". If you are happy with the result after restoring then just rename the two networks and move the devices across.
- If you really want to overwrite existing settings in an existing network then you can always change the restore script to just overright the section of interest.
- All restored networks will support all Meraki device types. So the network you backed up might not have any Meraki phones, but the restored network will have a section for Meraki Phones - but with no configuration.
- You can use the backup/restore system for creating your own automation scripts. Just configure something like you want in the Dashboard, back it up, and then you can edit and copy and paste the meraki-restore.py script to use it to automate the creation of further networks.