Fortinet Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
MarioZ
New Contributor

Automation -> CLI Script: Use date as Part of filename

Hello 
we use automation/cli script to backup the configuration.
How can i use the date in the filename?
Is there a parameter like %%date%%?
So that a backup would look like:
execute backup full-config ftp /Folder/backup_%%date%%.cfg user pwd

thanks for any input.

Regards
Mario

MaZi
3 REPLIES 3
bpozdena_FTNT

Hi Mario,

 

if you followed my advise from your yesterday's question and used Automation Stitch to run the backup script, you can use variables %%log.date%% and %%log.time%% .  The most appropriate triggers would likely be configuration change or schedule

 

Action example:

config system automation-action
    edit "sftp_backup"
        set action-type cli-script
        set script "config global
exec backup config sftp /<path>/backup_%%log.date%%_%%log.time%%.cfg <server_IP> <username> <password>"
        set accprofile "super_admin"
    next
end

 

I would highly suggest you to use the GUI wizard for automation stitches if you are not yet familiar with the CLI. 

 

HTH,

Boris

tobannon

Ok, I'm not sure if this is a bug but I've created two automation tasks.  One for capturing the FGT config every night at 12:15a and one that captures changes made during the day and saving them to an FTP server.  Nothing fancy.

 

Run this script on config changes (works as expected):

execute backup config ftp /HOSTNAME/"changes_backup_%%date%%.conf" <IP ADDRESS> <user> <password>

 

Run this script on a schedule (names the file with the %%date%%):

execute backup config ftp /HOSTNAME/"sched_backup_%%date%%.conf" <IP ADDRESS> <user> <password>

 

I've copied and pasted these commands numerous times and even tried on two different FGTs.  Both are running 6.4.8 b1914.  I've looked and cannot find a bug for this issue.  

 

I did even take the %%log.date%% hoping that would work and I get the exact same results in both commands.

 

TIA

bpozdena_FTNT

Please upgrade to FortiOS 7.0.1 or newer to fix bug 719029 .

 

Alternatively raise support ticket for FortiOS 6.4.