cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Backup Script Cisco Nexsus

Custom Backup Script Cisco Nexsus

Anonymous
Not applicable

Hi,

Had to create a custom backup script for a Cisco Nexus as the boxed one was failing, the script looks like the following:

-- Use these scripts to manage Cisco devices
name="Cisco Systems Adapted - TFTP"
desc="Cisco Systems NEXSUS SSH/TFTP Scripts"
protocol=TFTP
--
-----BEGIN SCRIPT "Configuration Upload"-----
copy running-config %TFTP_URL%
@KEY %0D
@receive 40
exit
-----END SCRIPT-----
-----BEGIN SUCCESS "Configuration Upload"-----
bytes copied
-----END SUCCESS-----
-----BEGIN SCRIPT "Configuration Download"-----
enable
%ENABLEPSWD%
copy %TFTP_URL% startup-config
startup-config
@receive 60
exit
-----END SCRIPT-----
-----BEGIN SUCCESS "Configuration Download"-----
bytes copied
-----END SUCCESS-----

This works without issue as shown with the inventory script verbose logs enabled in XMC, below is an extract from the server.log file showing the commands where successful:

BHR_N9K_2# copy running-config tftp://10.10.15.50/configs/tmp/10_10_15_247.cfg
Enter vrf (If no input, current vrf 'default' is considered):
Trying to connect to tftp server......
Connection to Server Established.
TFTP put operation was successful
Copy complete.
BHR_N9K_2# exit


2019-11-05 22:07:22,300 DEBUG [com.ets.netsight.inv.agent.ScriptMib] [Inventory Snmp-10] [ScriptMib] [10.10.15.247] Looking for success regex match: bytes copied:
2019-11-05 22:07:22,300 DEBUG [com.ets.netsight.inv.agent.ScriptMib] [Inventory Snmp-10] [ScriptMib] [10.10.15.247] No match for success regex match: bytes copied:

So the script is executing without error but is showing a failure in XMC:

 

643f6072d31a42a88ba5e968a7b1adbd_be104e0d-861b-42b0-9cbb-501b80b6e068.png

 

643f6072d31a42a88ba5e968a7b1adbd_39ca039e-929d-4808-a67e-70a53cd20484.png

 

The only bit I am considering as perhaps the issue are the last two lines in the server.log file given above:

 

2019-11-05 22:07:22,300 DEBUG [com.ets.netsight.inv.agent.ScriptMib] [Inventory Snmp-10] [ScriptMib] [10.10.15.247] Looking for success regex match: bytes copied:
2019-11-05 22:07:22,300 DEBUG [com.ets.netsight.inv.agent.ScriptMib] [Inventory Snmp-10] [ScriptMib] [10.10.15.247] No match for success regex match: bytes copied:

 

I’m not sure if this is why or what regex match is configured or looking for? Maybe a match on the ‘Copy Complete’ on the Cisco transcript when the TFTP upload has been completed?

 

Thanks in advance.

1 ACCEPTED SOLUTION

Zdeněk_Pala
Extreme Employee

Hi Marin.

the script does expect text “bytes copied

the cisco does report “Copy complete”.

As these doe not match => the backup failed.

change the BEGIN SUCCESS section and you will be good.

then please share, so others can benefit also.

 

Regards Zdeněk Pala

View solution in original post

3 REPLIES 3

Zdeněk_Pala
Extreme Employee

Thank you for sharing! The GitHub CFG section. The script itself.

Ideas for improve:

  • timed reset
  • firmware upgrade

Feel free to share if you update!

Regards Zdeněk Pala

Anonymous
Not applicable

Thanks Z, worked perfectly as you said. Script below, download section needs amending and testing, but easy enough now the detail has been teased out with the upload section:

 

-- Use these scripts to manage Cisco devices
name="Cisco Systems Adapted - TFTP"
desc="Cisco Systems NEXSUS SSH/TFTP Scripts"
protocol=TFTP
--
-----BEGIN SCRIPT "Configuration Upload"-----
copy running-config %TFTP_URL%
@KEY %0D
@receive 40
exit
-----END SCRIPT-----
-----BEGIN SUCCESS "Configuration Upload"-----
Copy complete.
-----END SUCCESS-----
-----BEGIN SCRIPT "Configuration Download"-----
enable
%ENABLEPSWD%
copy %TFTP_URL% startup-config
startup-config
@receive 60
exit
-----END SCRIPT-----
-----BEGIN SUCCESS "Configuration Download"-----
bytes copied
-----END SUCCESS-----

Appreciate the help.

Zdeněk_Pala
Extreme Employee

Hi Marin.

the script does expect text “bytes copied

the cisco does report “Copy complete”.

As these doe not match => the backup failed.

change the BEGIN SUCCESS section and you will be good.

then please share, so others can benefit also.

 

Regards Zdeněk Pala
GTM-P2G8KFN