Fortigate- Backup Script

Backup and restore a configuration file using SCP
First of all enable SCP:

config system global
set admin-scp enable
Use the same commands to backup a VDOM configuration by first entering the commands:
config global
set admin-scp enable
config vdom

Example of bat file:
————————Start forti_BCKP.bat————————-

@echo off

forfiles -p "D:\FORTI-backup" -s -m *.* /D -30 /C "cmd /c del /Q /S @path"

pscp -pw [email protected]@P -l your_user D:\FORTI-backup\FWBG.conf
"C:\Program Files\WinRAR\WinRAR.exe" a -m3 -s -y -ep1 -r -ta -pYour_rar_Pass "D:\FORTI-BCKP\FORTI-backup.rar" "D:\FORTI-backup\FWBG.conf"
del D:\FORTI-backup\FWBG.conf

wscript "C:\backup\FortiBackup-Email_Notification.vbs"

ren “D:\FORTI-backup\FORTI-BCKP.rar” “FortiBCKP-%date:/=-% %time::=-%.rar”
————————End forti_BCKP.bat————————-

————————Start FortiBackup-Email-Notification.vbs————————-

Set objMail = CreateObject("CDO.Message")
Set objConf = CreateObject("CDO.Configuration")
Set objFlds = objConf.Fields
objFlds.Item("") = 2 'cdoSendUsingPort
objFlds.Item("") = "Your_Smtp_Server" 'your smtp server domain or IP address goes here
objFlds.Item("") = 25 'default port for email
'uncomment next three lines if you need to use SMTP Authorization
'objFlds.Item("") = "your-username"
'objFlds.Item("") = "your-password"
'objFlds.Item("") = 1 'cdoBasic
objMail.Configuration = objConf
objMail.From = "[email protected]"
objMail.To = "[email protected]"
objMail.Subject = "Forti-Backup"
objMail.TextBody = "Please check attachment"
objMail.AddAttachment "D:\FORTI-backup\FORTI-BCKP.rar"
Set objFlds = Nothing
Set objConf = Nothing
Set objMail = Nothing

————————End FortiBackup-Email-Notification.vbs————————-