11-05-2019 10:19 PM
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:
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.
Solved! Go to Solution.
11-05-2019 10:24 PM
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.
11-06-2019 07:35 AM
Thank you for sharing! The GitHub CFG section. The script itself.
Ideas for improve:
Feel free to share if you update!
11-06-2019 12:08 AM
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.
11-05-2019 10:24 PM
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.