It seems like your browser didn't download the required fonts. Please revise your security settings and try again.
Barracuda CloudGen Firewall

This Firmware Version Is End-Of-Support

Documentation for this product is no longer updated. Please see End-of-Support for CloudGen Firewall Firmware for further information on our EoS policy.

Example - Create box.par Archive Files Using a Cronjob at Regular Intervals

  • Last updated on

The instructions should be followed only by an expert admin. The following example regularly allocates storage space on the firewall. Therefore, to free storage space, it is strongly recommended to discard the example schedule from the table and the demo directories and backup files if no longer needed.

The following example illustrates how to create archive files from a box for backup purposes at regular intervals. For this task, the executing script calls a tool named phionar which is located under the path /opt/phion/bin/. Phionar takes the contents of the directory /opt/phion/config/configroot as a template for creating the backup archive file. For creating a complete, unencrypted archive with the name box_[Year-Month-Day-Hour-Minute].par in the directory /usr/local/bin/backups, this information must be organized into an executable script file. It is recommended to store the script into a directory that is located outside of directories handled by the system, i.e., /usr/local/bin/userscripts.

Step 1. Create a Directory for Your Scripts and Your Backups on Your Firewall
  1. Log into your firewall on box level.
  2. Go to SSH and log into your firewall as user 'root'.   
  3. If not already present, create the directory for your backup files, i.e., /usr/local/bin/backups
  4. If not already present, create the directory for your script, i.e., /usr/local/bin/userscripts
  5.  Change to the newly created script directory.
cd /usr/local/bin
mkdir ./backups
mkdir ./userscripts
cd /usr/local/bin/userscripts
Step 2. Create an Executable Script with the Name boxpar_creator.sh, Save It in the Directory /usr/local/bin/userscripts and Make It Executable:
  1. Create the script in your preferred editor.

    #!/bin/bash
    ###########################################################################
    # 1. CREATE AN ARCHIVE FROM THE CONFIGURATION OF THE BOX
    # 2. NAME THE FILE: box_[Year-Month-Day-Hour-Minute].par, i.e. box_2017-07-14-10-00.par
    # 3. SAVE THE FILE IN DIRECTORY /usr/local/bin/backups using a variable.
    #  
    # Current configuration template lives in /opt/phion/config/configroot.
    # Call 'phionar' for creating the backup using the configuration template.
    ###########################################################################
    
    BACKUPDIR=/usr/local/bin/backups
    currentdate=$(date +'%Y-%m-%d-%H-%M')
    ARCHIVENAME=box_$currentdate.par
    
    cd /opt/phion/config/configroot
    /opt/phion/bin/phionar cdl ${BACKUPDIR}/${ARCHIVENAME} *
  2. Save the script in the directory /usr/local/bin/userscripts with the name boxpar_creator.sh
  3. Make the script executable with the command chmod ugo+x boxpar_creator.sh
Step 3. Configure a Cronjob that Executes the Script Every Second Hour
  1. Go to Box > Advanced Configuration > System Scheduler.
  2. In the left menu, click Daily Schedule.
  3. Click Lock.
  4. In the Intraday Schedule section, click +.
  5. Enter the name for your intraday schedule, i.e., BoxPar creator 
  6. Click OK. The Intraday Schedule window opens.
  7. Enter the Description for your schedule to be BoxPar creator every 2nd hour
  8. Click the green +.
  9. Enter the full path name, including the name of the script.
  10. From the Hourly Schedule list, select every.
  11. For Run Every .. Hours, enter 2
  12. Click OK.
  13. Click Send Changes.
  14. Click Activate.
    boxpar_creator_every_2nd_hour.png

Verify that the par files have been created under the path /usr/local/bin/backups

Note that depending on the lag between your current time and the configured pending cronjob, you will probably have to wait some time until the first archive file is created. Due to different schedule times, the timestamp (date, time) as part of the file name might differ.
[2017-07-17 08:14 CEST] [-root shell-] [-Barracuda Networks-]
[root@CC3:~]# cd /usr/local/bin/backups
[2017-07-17 08:14 CEST] [-root shell-] [-Barracuda Networks-]
[root@CC3:/usr/local/bin/backups]# ls -la
total 1040
drwxr-xr-x  2 root root   4096 2017-07-17 08:13 .
drwxr-xr-x 26 root root   4096 2017-07-14 12:05 ..
-rw-------  1 root root 346118 2017-07-14 09:00 box_2017-07-14-10-00.par
-rw-------  1 root root 346118 2017-07-15 09:00 box_2017-07-15-12-00.par
-rw-------  1 root root 346118 2017-07-16 09:00 box_2017-07-16-14-00.par
[2017-07-17 08:14 CEST] [-root shell-] [-Barracuda Networks-]
[root@CC3:/usr/local/bin/backups]#

Step 4. Unschedule Experimental Cronjob and Remove Unneeded Script and Backup Files

After your have successfully created a script executed via a scheduled cronjob at regular intervals, it is recommended to unschedule the cronjob and to delete all previously created experimental files.

  1. Go to Box > Advanced Configuration > System Scheduler.
  2. In the left menu, click Daily Schedule.
  3. Click Lock.
  4. In the Intraday Schedule table, select your entry for your daily schedule and click x to delete it.
  5. Click Send Changes.
  6. Click Activate.
  7. Go to SSH and log into your firewall as user 'root'.  
  8. Delete the previous created directories (userscripts, backups) with the contained scripts and backup files.

    cd /usr/local/bin
    rm -r ./backups
    rm -r ./userscripts