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](https://somoit.net/content/images/2016/07/Cisco-Ironport-automated-commands.jpg)
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](https://somoit.net/content/images/2016/07/Task-scheduler-Cisco-Ironport-ESA-script-1.jpg)
Program/Script | D:\SCRIPTS\IRONPORT\plink.exe |
Arguments | MYIRONPORT -i IRONPORT.ppk -l admin "mailconfig user@domain.com" |
Start in | D:\SCRIPTS\IRONPORT |
Everytime the task is executed the configuration would be received on our email client…
![Ironport ESA configuration file received via email](https://somoit.net/content/images/2016/07/Cisco-Ironport-ESA-email-configuration.jpg)
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](https://somoit.net/content/images/2016/07/Cisco-Ironport-automated-commands-2.jpg)
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](https://somoit.net/content/images/2016/07/Task-scheduler-Cisco-Ironport-ESA-script-2.jpg)
Program/Script | D:\SCRIPTS\IRONPORT\CONFIG_BACKUP.bat |
Arguments | |
Start in | D:\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](https://somoit.net/content/images/2016/07/Cisco-Ironport-ESA-backup-configuration.jpg)