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
- Log into your firewall on box level.
- Go to SSH and log into your firewall as user 'root'.
- If not already present, create the directory for your backup files, i.e.,
/usr/local/bin/backups
- If not already present, create the directory for your script, i.e.,
/usr/local/bin/userscripts
- 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:
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} *
- Save the script in the directory
/usr/local/bin/userscripts
with the nameboxpar_creator.sh
- 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
- Go to Box > Advanced Configuration > System Scheduler.
- In the left menu, click Daily Schedule.
- Click Lock.
- In the Intraday Schedule section, click +.
- Enter the name for your intraday schedule, i.e.,
BoxPar creator
- Click OK. The Intraday Schedule window opens.
- Enter the Description for your schedule to be
BoxPar creator every 2nd hour
- Click the green +.
- Enter the full path name, including the name of the script.
- From the Hourly Schedule list, select every.
- For Run Every .. Hours, enter
2
- Click OK.
- Click Send Changes.
- Click Activate.
Verify that the par files have been created under the path /usr/local/bin/backups
[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.
- Go to Box > Advanced Configuration > System Scheduler.
- In the left menu, click Daily Schedule.
- Click Lock.
- In the Intraday Schedule table, select your entry for your daily schedule and click x to delete it.
- Click Send Changes.
- Click Activate.
- Go to SSH and log into your firewall as user 'root'.
Delete the previous created directories (userscripts, backups) with the contained scripts and backup files.
cd /usr/local/bin rm -r ./backups rm -r ./userscripts