Skip to main content
itsupport-amagi
New Member
June 6, 2023
Question

FortiGate Firewall Automated config backups to FTP server

  • June 6, 2023
  • 9 replies
  • 13125 views

Hello,

As per the technical tip: https://community.fortinet.com/t5/FortiGate/Technical-Tip-How-to-send-automated-backups-of-the-configuration/ta-p/198364 , we have configured automated system backup to an FTP site.
Eg: execute backup config ftp /net-devices-auto-bkp/BACKUP.conf ftp ftp-server-name ftp-username ftp-password

We want the backups to be like: 

BACKUP-File-Name= FGT-HOSTNAME-date-timestamp.conf 
- Here
HOSTNAME = Fortigate Firewall Hostname
Date = Date of backup

timestamp = timestamp

 

Hence we are trying to execute the script as :

execute backup config ftp /net-devices-auto-bkp/bkp-FGT-HOSTNAME-%%date%%-%%time%%.conf ftp-server-name ftp-username ftp-password

 

However the file that gets saved in FTP server folder is : bkp-FGT-HOSTNAME-%%date%%-%%time%%.conf

 

It should have saved it as : bkp-FGT-HOSTNAME-actual-date-actual-time.conf

 

How do we resolve this ?

 

 

9 replies

srajeswaran
Staff
Staff
June 6, 2023

The configuration looks fine.
How are you testing the configuration? Please use  "Test automation stitch"  option from "stitch" tab /right click on stitch. If you directly run the command on CLI, it won't have the event date/time parameters and the file name will be what you see now.


If the FTP server is windows based, then we cannot use "%%time%%" as windows don't allow file name with ":".
date and time works fine with linux based FTP server.

itsupport-amagi
New Member
June 6, 2023

Even it does not work through automation stich and the FTP server runs on *NIX OS

Yurisk
SuperUser
SuperUser
June 6, 2023
yurisk.info - all things Fortinet blog, no ads
itsupport-amagi
New Member
June 7, 2023

Automation Stich is 

config system automation-action     edit "automation script"         set action-type cli-script         set minimum-interval 0         set delay 0         set required enable         set script "execute backup config ftp /net-devices-auto-bkp-to-g-drive/bkp-%%hostname%%-%%date%%_%%time%%.conf FTP-Server FTP-user FTP-user-pwd"     next end config system automation-trigger 	edit "test"         set trigger-type scheduled         set trigger-frequency daily         set trigger-hour 5         set trigger-minute 5     next end config system automation-stitch edit "test"         set status enable         set trigger "test"         set action "automation script"     next end

 System Info is:

# get system status Version: FortiGate-100E v6.2.3,build1066,191218 (GA)  # execute date current date is: 2023-06-07  # execute time current time is: 05:56:32 last ntp sync:Fri Mar 31 11:06:42 2023

The backup file that gets stored in FTP server is :

bkp-%%hostname%%-%%date%%_%%time%%.conf

Hence, the hostname, date and time are not at all substituted by actual values

itsupport-amagi
New Member
June 7, 2023

Also, we tried the same in versions 6.4.8 , 7.0.5 and the results are the same 

Chethiya
New Member
September 18, 2023

Does this script work for SFTP as well?

hbac
Staff
Staff
September 20, 2023

Hi @itsupport-amagi,

 

Please try %%log.date%% and %%log.time%% instead. Please refer to https://community.fortinet.com/t5/FortiGate/Technical-Tip-Automated-configuration-backups-with-variable/ta-p/212020

 

Regards,

Thought Leadership Security Summit. Outpace New Threats with AI - enhanced defense. Tuesday, Septmeber 15, 8:30 AM - 2:30 PM PT. The Golf Club at Newcastle, WA.
Fortinet Flag the Hack. Wednesday, August 26, 9:00 AM - 5:00 PM ET, COSM, Atlanta, GA.
Virtual event | September 2026. SASE summit. The age of autonomous trust. Register here!