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

Automated config backup with date

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,

8 REPLIES 8
lobstercreed
Valued Contributor

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

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
Esteemed Contributor III

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

 

PCNSE 

NSE 

StrongSwan  

PCNSE NSE StrongSwan
fm_fischer
New Contributor

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

Technical Tip: How to download a FortiGate configuration file and upload firmware file using secure ...   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#

Thanks

Kangming

emnoc
Esteemed Contributor III

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

PCNSE 

NSE 

StrongSwan  

PCNSE NSE StrongSwan
Kangming

emnoc wrote:

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

Yes, it's better. 

Thank you for sharing, I'd like to study Linux Shell well, this is very useful!

Thanks

Kangming

kangpaidjo
New Contributor

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

Announcements

Select Forum Responses to become Knowledge Articles!

Select the “Nominate to Knowledge Base” button to recommend a forum post to become a knowledge article.

Labels
Top Kudoed Authors