Jetserver – The Lazy Admin Blog
Home  /  cPanel • JetBackup  /  cPanel Backup – Mount / Unmount local backup destination

cPanel Backup – Mount / Unmount local backup destination

elialum July 13, 2018 Leave a Comment

It is very common for cPanel administrators to backup their data to a mountable folder. It could be either an NFS mount, or any other iSCSI / XFS / EXT mount – as long as it’s an external disk. To make your valuable backup data extra safe & secure, system administrators will want to unmount the backup drive as long as you are not using the backups.

As far as we know, this is not achievable with traditional cPanel backup, however this feature is obtainable using an external cPanel backup plugin like JetBackup. Besides being a very rich, secure and fast backup solution for a cPanel server, JetBackup also utilizes a “hooks system” giving you the power to run your own scripts in a pre or post JetBackup command with the ability to take action (like issuing an abort command for example).

The following is not officially supported by JetBackup, and there is no “out of the box” solution. In the following scenario, we will explain how to mount/unmount. Your actual implementation and use will likely vary from the example provided. Since we do not know your specific server setup, proceed at your own risk. We assume that you are using a “/backup” folder as a mountable drive for your backups and of course using at least JetBackup 3.3+ to backup your data.

We’ve created 14 hook points, that will execute a mount / unmount script for any JetBackup action that needs access to the backup folder – Backup, Clone, Crons, Download, Reindex, Restore & Snapshots.

For easier maintenance, we used a bash script for the mount / unmount command. Although you can do it straight forward, i.e “unmout /backup”, we wanted to use an external script so we can add some more validation, and take actions in case of error. As you can see in the screenshot above, here are the scripts we used –

The pre hook mount script ‘/ofir/scripts/mount.sh’

#!/bin/bash
DESTINATION=/backup
FLAG=$DESTINATION/unmounted.flag 

# if flag file exists, this means destnation is _unmounted_
if [ ! -f $FLAG ]; then
        echo "already mounted, aborting..."
        exit 0
fi

# If mount fails for any reason by the operating systems, exit codes will go back to JetBackup and it will abort / continue according to the exit codes.
mount $DESTINATION

The post hook mount script ‘/ofir/scripts/unmount.sh’

#!/bin/bash
DESTINATION=/backup
FLAG=$DESTINATION/unmounted.flag 

# Abort unmount script if there is JetBackup running jobs
if [ `jetapi backup -F listBackupJobs | grep 'running: 1'` ]; then
        exit 0
fi

# Abort unmount script if there is JetBackup clone running jobs
if [ `jetapi backup -F listCloneJobs | grep 'running: 1'` ]; then
        exit 0
fi


# Abort unmount script if there is JetBackup reindex running jobs
if [ `jetapi backup -F listDestinations | grep 'running: 1'` ]; then
        exit 0
fi

# Abort unmount script if there is any JetBackup action in the queue (download, restore etc..)
for i in `jetapi backup -F listQueueItems | grep 'status:' | awk '{print $2}'`; do
        if [ $i -lt 100 ]; then
                exit 0
        fi
done

# If flag file exists, this means destnation is already unmount, no need to take action
if [ -f $FLAG ]; then
        exit 0
fi

umount $DESTINATION

Thank you for reading ! 🙂

Tags: cPanel, JetBackup
Previous Article
Next Article

About Author

elialum

Related Posts

  • Building your own private cloud

    Building your own private cloud

    April 20, 2021
  • JetBackup :: Restore on steroids !

    JetBackup :: Restore on steroids !

    August 21, 2020
  • cPanel :: Safely restore an account after enabling NGiNX

    cPanel :: Safely restore an account after enabling NGiNX

    May 23, 2019

Leave a Reply

Cancel reply

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

Search Our Blog

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Filter by Categories
Apache
CentOS
CloudLinux
cPanel
ESXI
iSCSI
JetBackup
Litespeed
MySQL
NGINX
Reduxio
SSL
Uncategorized
VMware
Wordpress
XEN

Tags

apache aspx backup CentOS cloudlinux cPanel CXS freetds google htaccess iscsi JetBackup Libmodsecurity litespeed modsec modsecurity mssql MySQL netapp nginx odbc php php.ini phpselector VMFS WHM xenserver

Popular Posts

  • Allow a cPanel server to run a VHOST from multiple IP addresses April 3, 2018
  • How To Install & Configure a Galera Cluster with MySQL on Centos 7 February 6, 2018
  • Libmodsecurity installation April 14, 2016
  • JetBackup Cheat Sheet :: Automatically Acknowledge Alerts November 15, 2018

Recent Posts

  • Building your own private cloud April 20, 2021
  • Dealing with aggressive bot scanners September 14, 2020
  • Litespeed Geo Location Redirect September 14, 2020
  • JetBackup :: Restore on steroids ! August 21, 2020

Recent Comments

  • Khan on Allow a cPanel server to run a VHOST from multiple IP addresses
  • Khan on Allow a cPanel server to run a VHOST from multiple IP addresses
  • Oleg Drabkin on Allow a cPanel server to run a VHOST from multiple IP addresses
  • Khan on Allow a cPanel server to run a VHOST from multiple IP addresses
  • Daniel on How To Install & Configure a Galera Cluster with MySQL on Centos 7
אחסון אתרים | JetApps