Automated backup solution for FortiGate firewalls using Ansible.
- ✅ Automated configuration backups
- ✅ Device information documentation
- ✅ Automatic retention management (configurable per device)
- ✅ Parallel execution for multiple devices
- ✅ Comprehensive error handling
- ✅ Audit logging
- ✅ Support for multiple device groups
pip3 install ansible fortiosapi
ansible-galaxy collection install -r requirements.yamlexport FORTIGATE_USER="admin"
export FORTIGATE_PASSWORD="YourPassword"Edit hosts.yaml and update IP addresses for your FortiGate devices.
# Backup all devices
ansible-playbook forti_backup.yaml
# Backup specific group
ansible-playbook forti_backup.yaml --limit production_fortigates
# Backup single device
ansible-playbook forti_backup.yaml --limit fw-prod-01fortigate-backup/
├── ansible.cfg
├── backup_fortigate.yaml
├── hosts.yaml
├── requirements.yaml
├── group_vars/
│ ├── all.yaml
│ └── fortigates/
│ ├── vars.yaml
│ └── vault.yaml
├── host_vars/
│ ├── fw-prod-01.yaml
│ ├── fw-prod-02.yaml
│ ├── fw-branch-01.yaml
│ ├── fw-branch-02.yaml
│ └── fw-dmz-01.yaml
└── backups/
└── backup.log
backup_dir: Backup storage locationretention_days: Default retention periodbackup_timestamp: Timestamp format
- Connection parameters (HTTPS, SSL, timeouts)
- Authentication configuration
- FortiGate-specific settings
- Device metadata (site, location, role)
- Custom retention periods
- Device-specific overrides
0 2 * * * cd /opt/fortigate-backup && source ~/.fortigate_credentials && ansible-playbook forti_backup.yamlSee deployment documentation for systemd timer setup.
- Use Ansible Vault for credential storage
- Set appropriate file permissions
- Secure backup directory
- Use dedicated API user with read-only access
ansible fortigates -m fortinet.fortios.fortios_monitor_fact -a "selector=system_status"ansible-inventory --host fw-prod-01ansible-playbook forti_backup.yaml -vvvMIT
Ehsan Momeni Bashusqeh, Network Automation Engineer