Scripting

Scripting SonicWalls Backups

Written by Marc-Andre

Here’s a script to automate the backups of all your SonicWalls. I have been using it on SonicOS version 6.x without any problem.

You will need:

  1. SSH enabled on your SonicWall interface
  2. a FTP server
  3. a server running linux (I use CentOS) with Expect installed

Enabling SSH on your SonicWall

For your SonicWall to accept SSH connections, click on Network –> Interfaces and select the interface you want to use.enabling SSH on SonicWall
Make sure the SSH box is checked.

Configuring the script to backup your SonicWall

This scripts uses a program called Expect to send SSH commands to your SonicWall. On CentOS, you can install Expect by running :

#yum install expect expectk

Create a file on your linux server and paste the script inside. Make sure to change the variables to match your environment. The variables that needs to be changed are the following:

  • line 22: replace YOUR_USERNAME with the username used to log into your SonicWall
  • line 24: replace YOU_PASSWORD with its password
  • line 26: replace THE_IP_OF_YOUR_SONICWALL with the actually IP address of your Sonicwall (ex: 10.0.0.1)
  • line 34: this is where you enter the info to connect to your FTP server. Replace YOUR_FTP_USERNAME:YOUR_FTP_PASSWORD@IP_OF_YOUR_FTP_SERVER/YOUR_FOLDER/ with the appropriate info. For example:

The script ends by writing the result to the end of the file /var/log/BACKUP-SONICWALLS.log

That’s it! Enable the execution of the script with the command

#chmod + x the_script_file

You are now able to backup your SonicWall with one simple command. You can copy and paste the script to backup as many SonicWalls as you need.

About the expert

Marc-Andre

I'm currently certified as a Cisco Certified Network Professional (CCNP) with a background as a system administrator. If you're in Montreal, send me an email. I'll be happy be to chat with you in person. Else, you can always find me in the forum.

Leave a Comment