Skip to main content
Minestrone
New Member
March 24, 2021
Question

Automated config backup with date

  • March 24, 2021
  • 3 replies
  • 22098 views

Hello everyone,

 

I would like to setup an automated backup of the config of my Fortigate 100E to an FTP server, I know that this is easily feasible and i've already done it but I would like not to erase each config backup after it's done for conservation purposes. My idea would be to put the date of the backup in the filename of the backup automaticly so the directory where it goes looks like that :

(DD-MM-YYYY)

 

24032021-backup.conf

23032021-backup.conf

22032021-backup.conf

............

 

After my research I haven't found anyway to do that (at least using CLI), any ideas ?

 

Have a nice day,

    3 replies

    lobstercreed
    New Member
    March 25, 2021

    If you figure it out from the FortiSide, let me know.  What we did was run a Powershell script against the FTP server to change the filename daily so the FGT pushes the file and then about 30 minutes later the script runs to rename it based on the date.  That way the next FGT push doesn't overwrite it.

    Minestrone
    New Member
    March 29, 2021

    It's funny because i'm currently doing the exact same thing, it's a bit of a workaround but it does the job :) I'll update this post if I find anything more straightforward.

    emnoc
    New Member
    March 29, 2021

    You should look at the fortios API you can do that with ease imho. I prefer scp-copy and that works flawlessly and you can set the name of the filename when you copy it. Search here for exampes with power-shell or bash scripting.

     

    Ken Felix

     

    fm_fischer
    New Member
    June 15, 2021

    Hello,

    is here some new Information about this ?

    Search vor this option too, safe Config External by sftp, but its overwrites daily.

     

    execute backup config ftp /Backups/fortigate/backup_%date%.cfg 192.168.1.232 fortigate pw

     

    cya

    Frank

    Kangming
    Staff
    Staff
    September 2, 2021
    Technical Tip: How to download a FortiGate configuration file and upload firmware file using secure file copy (SCP)   root@pc1:/home/test/Desktop# scp admin@10.6.30.90:sys_config /home/test/Desktop sys_config                                                                                       100%  597KB 596.6KB/s   00:00     root@pc1:/home/test/Desktop# root@pc1:/home/test/Desktop# ls 1  iperf2.txt  iperf.txt  Old Firefox Data  sys_config root@pc1:/home/test/Desktop# mv sys_config fgt_sys_config.`date +%Y_%m_%d_%H_%M_%S`.conf root@pc1:/home/test/Desktop# ls 1  fgt_sys_config.2021_09_02_11_17_34.conf  iperf2.txt  iperf.txt  Old Firefox Data root@pc1:/home/test/Desktop#
    emnoc
    New Member
    September 2, 2021

    tip: you can set the scp download file name during the scp to save on a step of renaming the file

     

    scp -P 2022  kfelix@192.168.1.99:sys_config ./file.`date +%Y_%m_%d_%H_%M_%S`.conf

     

    http://socpuppet.blogspot.com/2015/10/fortigate-configuration-files-backups.html

     

    Ken Felix

    kangpaidjo
    New Member
    December 1, 2021

    create automation backup to Windows server

    exec backup full-config ftp backup/forti-full-config.conf 192.168.20.248:2021 username password

     

    then create script command shell, save this script file type .bat

     

    @echoOFF

    :PREPARE DATE STAMP
    SET YEAR=%date:~6,4%
    SET MONTH=%date:~3,2%
    SET DAY=%date:~0,2%

    D:
    cd backup\forti\backup

    REN forti-full-config.conf %YEAR%%MONTH%%DAY%-forti-full-config.conf

     

    create new task schedule and done.

    can also be applied on a linux server with shell script