This article describes how to indicate the date in the file name in relation to FortiGate's automatic backup.
FortiGate v7.0, v7.2, v7.4.
Step 1: Configure the automation trigger (see Automation stitches).
Settings to schedule automatic backup every 2 AM.
config system automation-trigger
edit "backup_test"
set trigger-type scheduled
set trigger-hour 02
set trigger-minute 00
next
end
Step 2: Configure automation-action.
Settings to perform backup using ‘CLI script’. Check the below.
To back up the configuration in FortiOS format using the CLI:
For FTP, note that port number and username are optional depending on the FTP site:
execute backup config ftp <backup_filename> <ftp_server>[<:ftp_port>] [<user_name>] [<password>] [<backup_password>]
Or for TFTP:
execute backup config tftp <backup_filename> <tftp_servers> [<backup_password>]
Or for SFTP:
execute backup config sftp <backup_filename> <sftp_server>[<:sftp_port>] <user> <password> [<backup_password>]
config system automation-action
edit "date_backup_test"
set action-type cli-script
set script "execute backup config sftp %%date%%.conf 10.0.3.225 admin qwe123"
set accprofile "super_admin"
next
end
If VDOM is enabled then add the 'config global' as below :
config system automation-action
edit "date_backup_test"
set action-type cli-script
set script "config global
execute backup config sftp %%date%%.conf 10.0.3.225 admin qwe123
end"
set accprofile "super_admin"
next
end
Step 3: Configure automation-stitch.
Combine step 1 and step 2 settings to create one automation configuration.
config system automation-stitch
edit "backup_test"
set status enable
set trigger "backup_test"
config actions
edit 1
set action "date_backup_test"
set required enable
next
end
next
end
Step 4: Result.
If the file name of the script set in step 2 includes '%%date%%', it includes the name of the backup date.
When performing a backup, the format of the variable changes to 'YYYY-MM-DD'.
For example 1:
set script "execute backup config sftp %%date%%.conf 10.0.3.225 admin qwe123"
2023-09-19.conf
2023-09-20.conf
For example 2:
set script "execute backup config ftp FGT_%%date%%_backup.conf 10.0.3.225 admin qwe123"
FGT_2023-09-19_backup.conf
FGT_2023-09-20_backup.conf
Caution:
Always verify if the script containing the date variable is correct. If the command via CLI Console or SSH is executed, it will not change.
It is necessary to check the results with the automation function.
%%date%%.conf
FGT_%%date%%_backup.conf
Also, there are instances when manually running the command on the CLI with a format like FGT_%%date%%_.conf, it will generate an untidy name and date result.
But if the command is set on the automation action script, a well-ordered name and date format of the backup configuration will be generated.
Related documents:
Technical Tip: Automated configuration backups with variable names based on the date
Configuration ba...
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.
Copyright 2024 Fortinet, Inc. All Rights Reserved.