The Lazy Admin Blog

Home  /  cPanel • JetBackup  /  cPanel Backup – Mount / Unmount local backup destination

cPanel Backup – Mount / Unmount local backup destination

July 13, 2018 cPanel, JetBackup 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

Related Posts

  • Convert JetBackup to cPanel structure

    Convert JetBackup to cPanel structure

    October 6, 2022
  • Enable TLS 1.1/1.0 on cPanel servers

    Enable TLS 1.1/1.0 on cPanel servers

    September 30, 2022
  • Building your own private cloud with XenServer

    April 20, 2021

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
Emails
ESXI
iSCSI
JetBackup
Linux
Litespeed
MySQL
NGINX
Oracle
Reduxio
Security
SSL
Uncategorized
VMware
Wordpress
XEN

Tags

apache aspx backup bash CentOS cloudlinux cPanel CXS Emails freetds google htaccess IMAP InnoDB iscsi JetBackup Libmodsecurity litespeed modsec modsecurity mssql MySQL netapp nginx odbc Oracle php php.ini phpselector rsync ssh ssmtp systemd threads VMFS WHM Wordpress xenserver

Popular Posts

  • Convert JetBackup to cPanel structure October 6, 2022
  • How To Install & Configure a Galera Cluster with MariaDB on Centos 7 February 6, 2018
  • Allow a cPanel server to run a VHOST from multiple IP addresses April 3, 2018
  • rsync without prompting for password October 10, 2022

Recent Posts

  • Understanding Why More Threads Can Sometimes Slow Down Performance October 9, 2024
  • Set up a new systemd service May 18, 2024
  • Bash Arrays November 7, 2023
  • rsync without prompting for password October 10, 2022

Recent Comments

  • Sven on rsync without prompting for password
  • TheLazyAdmin on rsync without prompting for password
  • Sven on rsync without prompting for password
  • TheLazyAdmin on Convert JetBackup to cPanel structure
  • Chris on Convert JetBackup to cPanel structure
Privacy Policy • Contact