Backup Netscaler using ansible

Back up the configuration of any device is a best practice in any technology field. Also backing up not only the configuration file but other relevant files of a device is also a good practice.
Netscaler backup by default every day everything that is in ” /nsconfig” folder. It creates an archive with all the contents of the folder, like SSL certificates, licenses, and ZebOS files (routing part).
Using this backup archive a restore of the whole appliance can be done very easily. But you first need to have the backups in another location, not on the device. If the device fails, you lost your backups. So having a central point (server) where you keep all your backups would be desired.

To tackle this scenario I have created a script/playbook in ansible that creates and downloads the backup using nitro API calls. It also does some cleanup by erasing the backup from the Netscaler. It saves the backup by default in the folder ” /home/ansible/ns_sys_backup “. But you can change it to whatever folder you want.
As the downloaded file is encoded in base64, there is a part that decodes the file and the output is the tar archive. It is using the base64 command under Linux.

Here you can find the files for this project:

About the author

Mihai is a Senior Network Engineer with more than 15 years of experience