IRONPORT icon   Ironport – Schedule automation scripts on Windows



On a previous post I explained how to Automate Ironport commands / scripts from Windows. At the end of the post I suggested configuring the task scheduler to execute a bat script, for example, to save a backup copy of the configuration… So, here we go!

Example 1: Simple configuration backup via email

Assuming all the necessary preparations are made, we should have a folder with the private key and some downloaded tools:
Folder with tools and generated public and private keys to connect to Ironport appliance

So, for example, this simple command forces the delivery of the configuration file to an email recipient:

D:\SCRIPTS\IRONPORT> plink.exe MYIRONPORT -i IRONPORT.ppk -l admin "mailconfig user@domain.com"

By scheduling the execution of this command, every day, or week (whatever you want), a backup of the Ironport would be made:
Scheduling a task to send the Ironport configuration file to email

Program/ScriptD:\SCRIPTS\IRONPORT\plink.exe
ArgumentsMYIRONPORT -i IRONPORT.ppk -l admin "mailconfig user@domain.com"
Start inD:\SCRIPTS\IRONPORT

Everytime the task is executed the configuration would be received on our email client…
Ironport ESA configuration file received via email

 

Example 2: Configuration file backup

In this example, a configuration file backup will be copied to a predefined folder (for example, to a UNC path in a shared folder on our file server).

A batch script is needed in order to get this work. I have called it CONFIG_BACKUP.bat:
Folder with tools and generated public and private keys to connect to Ironport appliance

This is the code:

@echo off

set TODAY_DATE=%date:~-4,4%%date:~-7,2%%date:~-10,2%
set BACKUPS_PATH="\\FILESERVER\EMAIL\IRONPORT\CONFIGURATION_BACKUPS"

plink.exe MYIRONPORT -i IRONPORT.ppk -l admin "saveconfig 3 yes"
pscp -i IRONPORT.ppk admin@MYIRONPORT:/configuration/*%TODAY_DATE%* MYIRONPORT_%TODAY_DATE%.xml

move *.xml %BACKUPS_PATH%\

The only customization is setting the BACKUP_PATH variable for you environment (it can be either a UNC or standard path). The script:
– executes the Ironport "saveconfig 3 yes" command to save a copy of the configuration on the appliance itself
– and then copies it to the defined path.

If executed manually. this would be the ouput:

D:\SCRIPTS\IRONPORT> CONFIG_BACKUP.bat

File written on machine "MYIRONPORT.domain.com" to the location
"/configuration/C380-00FEC85863DE-FCH1951V21D-20160719T085024.xml".
Configuration saved.
MYIRONPORT_20160719.xml        | 158 kB | 158.9 kB/s | ETA: 00:00:00 | 100%
D:\SCRIPTS\IRONPORT\MYIRONPORT_20160719.xml
        1 file(s) moved.

To schedule the execution:
Scheduling a task to backup the Ironport configuration file

Program/ScriptD:\SCRIPTS\IRONPORT\CONFIG_BACKUP.bat
Arguments
Start inD:\SCRIPTS\IRONPORT

Everytime the task is executed, a new configuration file with the date will be added to the configured path:
Ironport configuration file backed up

2 thoughts on “Ironport – Schedule automation scripts on Windows

  1. Nice article! It greatly helped me to back up my IronPort devices.
    Thanks a lot!

    I also tried to include a command to remove the generated config file from the IronPort device, but IronPort returns an error saying “you do not have access to the rm command.”
    According to some Cisco engineers on support forums, the only ways to remove such file is to do it manually through FTP or asking TAC to manually remove it.

    Because the backup files are only 250KB, it is finally not a big deal to keep them on device.

    Sylvain.

Leave a Reply

Your email address will not be published. Required fields are marked *