Backup Dell SonicWALL configurations via CLI

At one of my my previous work places we utilize multiple Dell SonicWALL network devices. I’ve written an Expect plus a BASH script (yes, two scripts) that can be cron job to auto backup configurations. We needed the Expect script to interact with SonicWall SSH session.

By looking at the BASH script you Just need to add/substract the proper associative array depending on how many devices you are backing up from.

SonicWALL exports configuration via FTP so you do need a FTP server setup. I have a ftpuser account setup with password of “ftpuser” and a folder called “network_configurations” under that user’s root directory. Both Expect and BASH scripts sits in /home/ftpuser/bin/scripts/. The server running this job and hosting the FTP server is

So if I want to add new SonicWALL device to the backup list, I’d just add something like following.

FWdevice[]="admin PASSWORD"


Expect script content:

#!/usr/bin/env expect

set server [lindex $argv 0];
set username [lindex $argv 1];
set userpw [lindex $argv 2];
set devicename [lindex $argv 3];

set timeout 60

spawn ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no [email protected]$server

expect -re ".*?assword:"
send "$userpw\n"

expect -re ">"
send "export current-config cli ftp ftp://ftpuser:[email protected]/network_configurations/$devicename.txt\n"

expect -re ">"
send "exit\n"


Bash script content:

#!/usr/bin/env bash

declare -A FWdevice

FWdevice[]="admin PASSWORD"
FWdevice[]="admin PASSWORD"
FWdevice[]="admin PASSWORD"
FWdevice[]="admin PASSWORD"

for v in ${!FWdevice[*]}
    echo "Working on saving configuration on network device $v..."
    /home/ftpuser/bin/scripts/sonicwallbackup.exp $v ${FWdevice[$v]} $v

exit 0


One Comment

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.