FortiGate
FortiGate Next Generation Firewall utilizes purpose-built security processors and threat intelligence security services from FortiGuard labs to deliver top-rated protection and high performance, including encrypted traffic.
sgiannogloudis
Article Id 212020
Description This article describes how to configure automation stitch settings to generate configuration files with different names based on the date the script triggers.
Scope FortiGate v6.4.9+ and v7.0.2+GA releases, 7.2.4.
Solution
  1. Create a trigger with the type 'Schedule'.

    The following script will be triggered daily at 20:00 (according to the time configured on FortiGate).

 

config system automation-trigger

edit "TFTP_Backup_Daily"

set trigger-type scheduled

set trigger-frequency daily

set trigger-hour 20

next

end

 

  1. Create an action with the 'CLI Script' type with a %%date%% variable:

 

config system automation-action

edit "backup_date"

set action-type cli-script

set script "execute backup config tftp Μy_Config_Name%%date%%.conf IP_Address Username Password"

set accprofile "super_admin"

next

end

 

  1. Create a stitch:

 

config system automation-stitch

edit "date_test"

set trigger "TFTP_Backup_Daily"

config actions

edit 1

set action "backup_date"

set required enable

next

end

end

 

  1. The configuration backup files on the TFTP server will then look like this:

 

Μy_Config_Name2022-08-19
Μy_Config_Name2022-08-20
Μy_Config_Name2022-08-21
Μy_Config_Name2022-08-22

 

Note: 

In v7.2.4, %%date%% and %%time%% do not work as expected in an automation stitch. Use %%log.date%% and %%log.time%% instead.


For example:

 

config system automation-action

edit "backup_date"

set action-type cli-script

set script "execute backup config tftp Μy_Config_Name%%log.date%%_%%log.time%%.conf IP_Address Username Password"

set accprofile "super_admin"

next

end

 

Note: 

%%time%% or %%log.time%% not working for some of the TFTP/SFTP/FTP servers as it analyzed as bad characters for the title.

 

Here is the output:

 

Screenshot 2023-08-18 163850.png

 

Note:

To check if the backup configuration is working with variables (date/ time) needs to be done using automation stitch only and does not change the variables if checking from CLI console or SSH.