cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
186892
Views
38
Helpful
90
Replies

MERAKI BACKUP AND RESTORE

ritchie.barral
Level 2
Level 2

Hi guys,

Good Morning.

Just want to hear your unique ways about how to backup your configuration in the dashboard to your local drive.

In my situation i had an MX65W with configurations already and then i will have a new MX65W coming to be use in another organization.

My question first is how can i backup my configuration from my existing MX65W so that i can use it to my new MX65W? (But this is answered already by meraki support so they provide me a link : https://documentation.meraki.com/zGeneral_Administration/Templates_and_Config_Sync/Cloning_Network_Settings_with_Configuration_Sync ).

In this link i just saw how to clone from network to another network in one organization.

Now, i want to hear from you guys if you experience this already and how you tried to backup from one organization to another organization.

Thanks in advance.

90 Replies 90

What's the output if you execute the following function from within python:

 help("modules")

Hi Phillip,

I'm facing this issue when starting the script:

----------------python3 meraki-backup.py "My Network"

Traceback (most recent call last):
File "meraki-backup.py", line 209, in <module>
orgid=get_org_id(meraki,args.orgName)
File "meraki-backup.py", line 33, in get_org_id
result = meraki.organizations.get_organizations()
File "/usr/local/lib/python3.6/dist-packages/meraki_sdk/controllers/organizations_controller.py", line 50, in get_organizations
self.validate_response(_context)
File "/usr/local/lib/python3.6/dist-packages/meraki_sdk/controllers/base_controller.py", line 94, in validate_response
raise APIException('HTTP response not OK.', context)
meraki_sdk.exceptions.api_exception.APIException: HTTP response not OK.

Philip D'Ath
Meraki Community All-Star
Meraki Community All-Star

HI @Alex07 .

I'm not sure what is causing that. Perhaps try update your modules:

pip install -U requests
pip install -U meraki-sdk
pip install -U python-dotenv

Double-check your API key is correct.

@Philip D'Ath - am I right to think that your script does not save switch configuration?
Great work on this btw.

Philip D'Ath
Meraki Community All-Star
Meraki Community All-Star

Correct @bdosen . At the time I wrote it, there wasn't an API available to get switch configuration.

One day I'll re-write it to use the V1 API and will be able to add more stuff in.

Hello @Philip D'Ath @ I've tried your new script for backup and i got the following error also here I'm using the Meraki Sanbox as testing purpose, post successful test will go for production unit.

Also please correct me if I'm wrong I'm using .env.meraki file for storing my API key.

x_cisco_meraki_api_key=bfddXXXXXXXXXXXXXXXXXXXXXXXXXXX0d88

I'm getting following error while execution

C:\Program Files\Python>python meraki-backup.py "Adecco_UAT"
Traceback (most recent call last):
File "C:\Program Files\Python\meraki-backup.py", line 209, in <module>
orgid=get_org_id(meraki,args.orgName)
File "C:\Program Files\Python\meraki-backup.py", line 33, in get_org_id
result = meraki.organizations.get_organizations()
File "C:\Users\p\AppData\Roaming\Python\Python39\site-packages\meraki_sdk\controllers\organizations_controller.py", line 50, in get_organizations
self.validate_response(_context)
File "C:\Users\p\AppData\Roaming\Python\Python39\site-packages\meraki_sdk\controllers\base_controller.py", line 94, in validate_response
raise APIException('HTTP response not OK.', context)
meraki_sdk.exceptions.api_exception.APIException: HTTP response not OK.

Also I've tested my all packages which are completely fine.

C:\Program Files\Python>pip install -U requests
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: requests in c:\users\p\appdata\roaming\python\python39\site-packages (2.25.1)
Requirement already satisfied: chardet<5,>=3.0.2 in c:\users\p\appdata\roaming\python\python39\site-packages (from requests) (4.0.0)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\p\appdata\roaming\python\python39\site-packages (from requests) (1.26.4)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\p\appdata\roaming\python\python39\site-packages (from requests) (2020.12.5)
Requirement already satisfied: idna<3,>=2.5 in c:\users\p\appdata\roaming\python\python39\site-packages (from requests) (2.10)

C:\Program Files\Python>pip install -U meraki-sdk
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: meraki-sdk in c:\users\p\appdata\roaming\python\python39\site-packages (1.5.0)
Requirement already satisfied: cachecontrol<1.0,>=0.11.7 in c:\users\p\appdata\roaming\python\python39\site-packages (from meraki-sdk) (0.12.6)
Requirement already satisfied: python-dateutil<3.0,>=2.5.3 in c:\users\p\appdata\roaming\python\python39\site-packages (from meraki-sdk) (2.8.1)
Requirement already satisfied: requests<3.0,>=2.9.1 in c:\users\p\appdata\roaming\python\python39\site-packages (from meraki-sdk) (2.25.1)
Requirement already satisfied: jsonpickle<1.0,>=0.7.1 in c:\users\p\appdata\roaming\python\python39\site-packages (from meraki-sdk) (0.9.6)
Requirement already satisfied: msgpack>=0.5.2 in c:\users\p\appdata\roaming\python\python39\site-packages (from cachecontrol<1.0,>=0.11.7->meraki-sdk) (1.0.2)
Requirement already satisfied: six>=1.5 in c:\users\p\appdata\roaming\python\python39\site-packages (from python-dateutil<3.0,>=2.5.3->meraki-sdk) (1.16.0)
Requirement already satisfied: idna<3,>=2.5 in c:\users\p\appdata\roaming\python\python39\site-packages (from requests<3.0,>=2.9.1->meraki-sdk) (2.10)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\p\appdata\roaming\python\python39\site-packages (from requests<3.0,>=2.9.1->meraki-sdk) (2020.12.5)
Requirement already satisfied: chardet<5,>=3.0.2 in c:\users\p\appdata\roaming\python\python39\site-packages (from requests<3.0,>=2.9.1->meraki-sdk) (4.0.0)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\p\appdata\roaming\python\python39\site-packages (from requests<3.0,>=2.9.1->meraki-sdk) (1.26.4)

C:\Program Files\Python>pip install -U python-dotenv
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: python-dotenv in c:\users\p\appdata\roaming\python\python39\site-packages (0.17.1)

Philip D'Ath
Meraki Community All-Star
Meraki Community All-Star

It is not spitting out any useful error. The SDK is having trouble getting the list of orgs.

Have you got API access enabled on the org?

I was able to fetched all details using Postman APIs in Sand Box, but while connecting given script getting the same this.

C:\Program Files\Python38>python meraki-backup.py "DevNet Sandbox"
Traceback (most recent call last):
File "meraki-backup.py", line 209, in <module>
orgid=get_org_id(meraki,args.orgName)
File "meraki-backup.py", line 33, in get_org_id
result = meraki.organizations.get_organizations()
File "C:\Users\rahul.dhawan\AppData\Roaming\Python\Python38\site-packages\meraki_sdk\controllers\organizations_controller.py", line 50, in get_organizations
self.validate_response(_context)
File "C:\Users\rahul.dhawan\AppData\Roaming\Python\Python38\site-packages\meraki_sdk\controllers\base_controller.py", line 94, in validate_response
raise APIException('HTTP response not OK.', context)
meraki_sdk.exceptions.api_exception.APIException: HTTP response not OK.

Is that anything related to Python installation ?

Philip D'Ath
Meraki Community All-Star
Meraki Community All-Star

>meraki_sdk.exceptions.api_exception.APIException: HTTP response not OK.

This is the most puzzling bit. It doesn't give any kind of specific error. Are you using Python 3.x?

Try checking that the modules are up to date.

pip install -U requests
pip install -U meraki-sdk
pip install -U python-dotenv

I have found the solution, its work from me .

1st check your API key is working.

by using below python temple.

import requests
payload = None
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"X-Cisco-Meraki-API-Key": "XXXXXXXXXXXXXXXXXXXXXXa0"
}
response = requests.request('GET', url, headers=headers, data = payload)
print(response.text.encode('utf8'))
If its working the API keys are fine .
Step 2
Next login to meraki portal and second tab use this URL to get org ID
Step 3
Now change the script and add org ID for which you want to take backup.
meraki = MerakiSdkClient(os.getenv("x_cisco_meraki_api_key"))
orgid="xxxxx9" # (At this place I have added the org ID. line number 209 hxxps://www.ifm.net.nz/cookbooks/meraki-backup.py in this script )
#get_org_id(meraki,args.orgName)
I don't know why org ID was not retrieving in original script .
Anyway. Thanks for building offline backup script @Philip D'Ath

Hi Philip,

is there any course you would recommend for network engineers to get familiar with Python? at least to be able to read and understand a code, and do minor fixes if the code through some errors.

Many thanks. @Philip D'Ath

Philip D'Ath
Meraki Community All-Star
Meraki Community All-Star

You could give the Cisco Meraki Python tutorial a try.

https://developer.cisco.com/meraki/

hey phillip , hoping you could help me out with this error ( latest 3.12 python installed )

c:\Python\Scripts>meraki-backup.py "SYDNIC Computer Systems"
Traceback (most recent call last):
File "C:\Python\Scripts\meraki-backup.py", line 213, in <module>
orgid=get_org_id(meraki,args.orgName)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python\Scripts\meraki-backup.py", line 37, in get_org_id
result = meraki.organizations.get_organizations()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\site-packages\meraki_sdk\controllers\organizations_controller.py", line 50, in get_organizations
self.validate_response(_context)
File "C:\Program Files\Python312\Lib\site-packages\meraki_sdk\controllers\base_controller.py", line 94, in validate_response
raise APIException('HTTP response not OK.', context)
meraki_sdk.exceptions.api_exception.APIException: HTTP response not OK.

c:\Python\Scripts>python3 meraki-backup.py "SYDNIC Computer Systems"
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

c:\Python\Scripts>python3 meraki-backup.py "SYDNIC Computer Systems"
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

c:\Python\Scripts>

This script is based on the V0 API, which is now deprecated.

Check out this back system provided in the sample Meraki automation scripts.

https://github.com/meraki/automation-scripts/tree/master/backup_configs

stephen-york
Community Member

Not sure about local drive but there are out of the box solutions that fill this gap. They also protect from malicious data deletion with SLA coverage. I have found this on Meraki marketplace

https://apps.meraki.io/en-US/apps/394857/dna-assure

https://www.devnetapps.io/our-apps/