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

FortiGate Firewall Automated config backups to FTP server

Hello,

As per the technical tip: https://community.fortinet.com/t5/FortiGate/Technical-Tip-How-to-send-automated-backups-of-the-confi... , 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 ?

 

 

itsupport-amagi
itsupport-amagi
9 REPLIES 9
srajeswaran
Staff
Staff

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.

Regards,

Suraj

- Have you found a solution? Then give your helper a "Kudos" and mark the solution.

itsupport-amagi

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

itsupport-amagi
itsupport-amagi
Yurisk
Valued Contributor

Also have a look at https://community.fortinet.com/t5/Support-Forum/backup-via-ftp/td-p/256544 

 

Yuri https://yurisk.info/  blog: All things Fortinet, no ads.
Yuri https://yurisk.info/ blog: All things Fortinet, no ads.
itsupport-amagi
New Contributor

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
itsupport-amagi
itsupport-amagi
New Contributor

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

itsupport-amagi
itsupport-amagi
Chethiya

Does this script work for SFTP as well?

StevenT

Hi guys,

I tested on firmware 7.4 and 7.2.5 to automate to send to ftp is working for %%date%% but if add the time script %%time%% , it failed. I using filezilla server on Win Server. The action I had set is using the CLI Script. 

CLI Script
/fgt-%%date%%-%%time%%_config.conf

The message stated in the ftp server:
Server Log
STOR fgt-2023-09-20-16:25:00_backup.conf
550 Invalid file name or path


CLI Script
/fgt-%%date%%_config.conf

The message stated in the ftp server:
Server Log
STOR fgt-2023-09-20_backup.conf
150 150 Starting data transfer
226 operation successful


I suspect is the semi-colon cause it on the file name. 
Does anyone know if there is any possible to add a cli script like a counter CLI?

srajeswaran

It is because windows don't accept file names with ":"

Regards,

Suraj

- Have you found a solution? Then give your helper a "Kudos" and mark the solution.

hbac
Staff
Staff

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-varia...

 

Regards,

Labels
Top Kudoed Authors