FortiGate Automated Config Backup using SFTP/FTP Server

This article does a great job of summarizing this process already, but I wanted to describe a few caveats and explain the formatting of the script a bit clearer:

https://community.fortinet.com/t5/FortiGate/Technical-Tip-How-to-send-automated-backups-of-the-configuration/ta-p/198364

Here is an example config of this with all of the required components:

conf system automation-action
	edit AutomatedConfigBackup 
	unset script
	set script "execute backup config ftp \"/Fortinet_Backups/FortigateBackup.conf\" 10.10.10.10 \"Domain\\UserHere\" PasswordHere"
end


config system automation-trigger
	edit "AutomatedConfigBackup"
	set trigger-type scheduled
	set trigger-hour 22
	set trigger-minute 58
	next
end


 edit "AutomatedConfigBackup_FTP"
        set trigger "AutomatedConfigBackup"
        config actions
            edit 1
                set action "AutomatedConfigBackup"
                set required enable
            next
end

All of this is easy enough to follow along, except for the format of the backup script and command itself. Let’s analyze this further to see why it is formatted as such:

set script "execute backup config ftp \"/Fortinet_Backups/FortigateBackup.conf\" 10.10.10.10 \"Domain\\UserHere\" PasswordHere"

With FortiOS and this “set script” command with quotes around it, you have to use the \ character to include the “” around the path and username so it includes it exactly.

You must have quotes around the path for it to work. For Windows use the / slash for the path and \ for the domain\user

From the documentation:

Special characters

The following characters cannot be used in most CLI commands: <, >, (, ), #, ‘, and “

If one of those characters, or a space, needs to be entered as part of a string, it can be entered by using a special command, enclosing the entire string in quotes, or preceding it with an escape character (backslash, ).

Leave a Reply

Your email address will not be published. Required fields are marked *