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

backup via ftp

Dear, i want to configure a schedule backup of my HA firewall 100F .

 I tried to exe this command via cli

 

execute backup config ftp /backupFW/backup_%date%.cfg 10.10.X.X backupfw test1

 

but i have this error:

 

Send config file to ftp server via vdom root failed

Command fail. Return code 12

 

I tested the ftp account with filezilla and i can log on the Ftp Server and the user had the RW permession on the ftp folder .

 

thanks

Antonio

8 REPLIES 8
pavankr5
Staff
Staff

Hello @tp-italia,

Could you please confirm if it is a new setup or was it working before.

 

The error message you received indicates that there was a problem sending the configuration file to the FTP server.
Check the firewall settings on both the FortiGate and the FTP server to ensure that FTP traffic is allowed.

Verify that the FTP username and password are correct and have the necessary permissions to write to the backup folder.
Verify that the backup folder exists and has the correct permissions.

https://community.fortinet.com/t5/FortiGate/Technical-Tip-How-to-send-automated-backups-of-the-confi... 


Backup of configuration file from CLI using FTP 

https://community.fortinet.com/t5/FortiGate/Technical-Tip-Backup-of-configuration-file-from-CLI-using-FTP/ta-p/212891

tp-italia
New Contributor II

Hi Pavankr5, this is a new setup for ftp service .

 

But i Resolve it with TFTP and not with FTP .

 

Is there a way to add the date to the file?

 

thanks

 

 

funkylicious

Hi,
If I recall corectly, manually setting that variable and executing the script won't display the date, you would need to create a automation task and it will be good.

geek
geek
tp-italia

ok thanks

Yurisk
Valued Contributor

Indeed,  put date/time into the back up file names you can only via automation stitches, not a regular scheduled back up. 

 

Here is such a stitch:

- Create a scheduled trigger, here it is 2 Am (at night) every day:

 

 

condfig sys automation-trigger
    edit "ScheduledBackup_trigger"
        set trigger-type scheduled
        set trigger-hour 2
        set trigger-minute 0
     next
end​

 

- Next, create action of backing up. Here, 

 

  • 10.10.10.13  - SFTP server to back up to (change to ftp if you'd like)
  • fgtbackup/fgPW39--7 - SFTP server username/password
  • fgtconfig-%%date%%-%%time%%.conf - Back up file name pattern

 

 

config sys automation-ation
    edit "ConfigBackupOnChange"
        set action-type cli-script
        set script " exe backup config sftp fgtconfig-%%date%%-%%time%%.conf
10.10.10.13 fgtbackup fgPW39--7"
        set accprofile "super_admin"
    next
end​

 

 

 

- Now, tie it all together:

 

config sys automation-stitch
    edit "BackUpDaily"
        set trigger "ScheduledBackup_trigger"
        config actions
            edit 1
                set action "ConfigBackupOnChange"
                set required enable
            next
            
        end
    next
end

 

 

As the result, the back up files on the SFTP server will look like:

 

# ls -1
fgtconfig-2023-03-14-02:01:49.conf
fgtconfig-2023-03-14-02:01:15.conf

 

HTH

Regards

Yuri https://yurisk.info/  blog: All things Fortinet, no ads.
Yuri https://yurisk.info/ blog: All things Fortinet, no ads.
CuervoLoco

Hi Yurisk,

 

I am using version 7.0.12 and everything works perfectly except the variables in the filename, I have tried all of these and none of them work.

%%log.time%%
%%log.date%%
%%log.devid%%
%%log.devname%%
%%date%%%
%%time%%%
%%devid%%%
%%deviceid%%

 

Do you know how I can know the variables used by this version?

 

Thanks.

CristianTudor

Hello, 

Today a project for FortiGate config backup via ftp needed this %%date%%% so we tried backup from the cli and the result on the ftp server what FGT_Config-%%date%%%.conf. After a short check on the forums we found no solution for this issue. At the end we tried running our automation stitch and the variable %%date%%% worked. Try running the script in automation stitch with super-admin and will work. Our FortiGate cluster has version  7.0.13.

rtichkule
Staff
Staff

Hello,

 

The command "execute backup config ftp backup.cfg 10.10.X.X backupfw test1" will generate a configuration backup file in the directory which is set in the FTP server. However the command "execute backup config ftp /backupFW/backup_%date%.cfg 10.10.X.X backupfw test1" will generate the backup in the directory /backupFW
If there is no directory with such name the server will respond with the error.

Either you can create a directory /backupFW in which the configuration backup will be saved or you can remove the path so that the backup will be saved in the current directory which is configured in the FTP server.

 

BR

Top Kudoed Authors