cancel
Showing results for 
Search instead for 
Did you mean: 

MERAKI BACKUP AND RESTORE

Getting noticed

MERAKI BACKUP AND RESTORE

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_S... ).

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.

24 REPLIES 24
Kind of a big deal

Re: MERAKI BACKUP AND RESTORE

Getting noticed

Re: MERAKI BACKUP AND RESTORE

Thanks @PhilipDAth , i would try this now.

Head in the Cloud

Re: MERAKI BACKUP AND RESTORE

Config Sync and Templates is the native way of replicating configuration from networks which need to be re-used and re-purposed else where.

 

If you're wanting to back-up the configuration to a local file you can do this via scripting and the API. @PhilipDAth has created a script for this purpose. I've tested it and works fantastic!

Eliot F | Simplifying IT with Cloud Solutions
Found this helpful? Give me some Kudos! (click on the little up-arrow below)
Getting noticed

Re: MERAKI BACKUP AND RESTORE

I found this erro when executing. I am not really familiar with python. 

meraki error local backup.PNG

Kind of a big deal

Re: MERAKI BACKUP AND RESTORE

Try changing these three lines from:

del mySNMP['v2CommunityString']
del mySNMP['hostname']
del mySNMP['port']

to:

if 'v2CommunityString' in mySNMP:

<tab>del mySNMP['v2CommunityString']

if 'hostname' in mySNMP:

<tab>del mySNMP['hostname']

if 'port' in mySNMP:

<tab>del mySNMP['port']

 

Make sure you replace "tab" with the tab key.  Formatting is very important in Python.  Let me know if it fixes it so I can update the main script.

Getting noticed

Re: MERAKI BACKUP AND RESTORE

Thanks @PhilipDAth I will update you once done executing.

Getting noticed

Re: MERAKI BACKUP AND RESTORE

C:\Users\Lenovo\Desktop>python meraki-backup.py [API-KEY] "Ardent Network Inc"
Processing network MY NETWORK
Processing network NGKHAI
HTTP Status Code: 404 - No returned data

Traceback (most recent call last):
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen
chunked=chunked)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 346, in _make_request
self._validate_conn(conn)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 850, in _validate_conn
conn.connect()
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\connection.py", line 326, in connect
ssl_context=context)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\util\ssl_.py", line 329, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\ssl.py", line 814, in __init__
self.do_handshake()
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\ssl.py", line 1068, in do_handshake
self._sslobj.do_handshake()
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\adapters.py", line 440, in send
timeout=timeout
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\util\retry.py", line 357, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\packages\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen
chunked=chunked)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 346, in _make_request
self._validate_conn(conn)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 850, in _validate_conn
conn.connect()
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\connection.py", line 326, in connect
ssl_context=context)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\util\ssl_.py", line 329, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\ssl.py", line 814, in __init__
self.do_handshake()
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\ssl.py", line 1068, in do_handshake
self._sslobj.do_handshake()
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionAbortedError(10053, 'An established connection was aborted by the software in your host machine', None, 10053, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "meraki-backup.py", line 184, in <module>
write_ssid_settings(file,apikey,row['id'],suppressprint)
File "meraki-backup.py", line 121, in write_ssid_settings
myRules=meraki.getssidl3fwrules(apikey, networkid, row['number'], suppressprint)[0:-2]
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\meraki\meraki.py", line 1703, in getssidl3fwrules
dashboard = requests.get(geturl, headers=headers)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 640, in send
history = [resp for resp in gen] if allow_redirects else []
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 640, in <listcomp>
history = [resp for resp in gen] if allow_redirects else []
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 218, in resolve_redirects
**adapter_kwargs
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\adapters.py", line 490, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionAbortedError(10053, 'An established connection was aborted by the software in your host machine', None, 10053, None))

Kind of a big deal

Re: MERAKI BACKUP AND RESTORE

Hi @Ritchie.  Just edit that last post and remove the API key from from the command line.  I'll have a look at the rest.

Kind of a big deal

Re: MERAKI BACKUP AND RESTORE

I see it got upset when retrieving the SSID Firewall rules. I haven't tested against a M65W before, so I'll go try that.

 

So the prior change I gave got you past the SNMP issue?

Kind of a big deal

Re: MERAKI BACKUP AND RESTORE

I have a couple of thoughts.

 

Are you perhaps using Python V2 instead of Python V3?  To force the version try:

python3 meraki-backup.py <api-key> "Ardent Network Inc"

 

I have also updated the script to include the SNMP fix, and an issue with SSIDs.  So you should download a fresh copy.  You may still get some errors, but you should get a reasonable restore script produced.

Getting noticed

Re: MERAKI BACKUP AND RESTORE

python3.6.PNG

 

 

I am using python 3.6

Head in the Cloud

Re: MERAKI BACKUP AND RESTORE

The old script worked with me fine with Python 3.6, all I did was go into my network-wide settings and just enabled SNMP and set anonymous community strings which did the trick.

Eliot F | Simplifying IT with Cloud Solutions
Found this helpful? Give me some Kudos! (click on the little up-arrow below)
Getting noticed

Re: MERAKI BACKUP AND RESTORE

I will check that.

MAG
Here to help

Re: MERAKI BACKUP AND RESTORE

I just tried the script and seems to work fine, at least i can not see any errors but where the results are written ??  which folder ?

Thanks

 

Kind of a big deal

Re: MERAKI BACKUP AND RESTORE

The results are written to the "current working directory" - so whatever directory you ran the command in, the restore script will be in.

MAG
Here to help

Re: MERAKI BACKUP AND RESTORE

oh ok , sorry Philip, i thougth that the results were written on a file other that the restore script. I see now that the "data" is inside the restore scripts itself. clear.

Thanks again.

Miguel Angel

Kind of a big deal

Re: MERAKI BACKUP AND RESTORE

Tried out the backup script. Had some problems getting it to run at first. Error was: 

TypeError: __init__() got an unexpected keyword argument 'strict'

Reason was an out-of-date requests library. Fixed that by using:

pip install --upgrade requests

 

For testing I had created a dummy network that didn't have actual hardware in it but had some hardware independent settings changed. Had problems creating a backup with that somewhat empty network in my org:

 

HTTP Status Code: 404 - No returned data

Traceback (most recent call last):
  File "meraki-backup.py", line 187, in <module>
    write_ssid_settings(file,apikey,row['id'],suppressprint)
  File "meraki-backup.py", line 124, in write_ssid_settings
    myRules=meraki.getssidl3fwrules(apikey, networkid, row['number'], suppresspr
int)[0:-2]
TypeError: 'NoneType' object is not subscriptable

 

 Although the backup without that network was successful I'm not really willing to try out whether restore works on my real networks.

 

I think that Meraki should allow for some kind of backup natively.

Kind of a big deal

Re: MERAKI BACKUP AND RESTORE

Thanks for the feedback!  I don't think I have tested it out on a network with no devices in it.  I'll give that a try sometime.

Here to help

Re: MERAKI BACKUP AND RESTORE

@PhilipDAth

Have you considered putting this script under version control on GitHub? Would be a great way to for people to track changes/updates and contribute to the code base.
Kind of a big deal

Re: MERAKI BACKUP AND RESTORE

I hadn't considered it.  I'm not a proper developer ...

Here to help

Re: MERAKI BACKUP AND RESTORE

I too am receiving errors when running the script. Both on Organizations with and without devices on their network. See below.

 

Python 3.6.5

requests  2.18.4

meraki 0.33

 

HTTP Status Code: 404 - No returned data

Traceback (most recent call last):
  File "meraki-backup.py", line 159, in <module>
    write_admins(file,apikey, orgid, suppressprint);
  File "meraki-backup.py", line 53, in write_admins
    for row in myOrgAdmins:
TypeError: 'NoneType' object is not iterable

 

New here

Re: MERAKI BACKUP AND RESTORE

Hey @WANKiller or @PhilipDAth  could you pleaes indicate me where is that script ? thanks in advance.

Kind of a big deal

Re: MERAKI BACKUP AND RESTORE

Check out the second post.

Highlighted
New here

Re: MERAKI BACKUP AND RESTORE

thanks Philip , good idea about that script btw . Regards
Welcome to the Meraki Community!
To start contributing, simply sign in with your Cisco account. If you don't yet have a Cisco account, you can sign up.