From 2878300e826436038827cc85a57f2e6a61e4ef0f Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Thu, 22 Apr 2021 15:03:50 -0700 Subject: [PATCH] reconfigured to use bashup.sh for common code --- README.md | 10 ++-- bashup-backup-files.sh | 102 ++------------------------------ bashup-backup-mysql.sh | 108 ++-------------------------------- bashup-backup-pdns.sh | 104 ++------------------------------- bashup-list-backups.sh | 46 +-------------- bashup-restore-files.sh | 48 ++------------- bashup-restore-mysql.sh | 50 ++-------------- bashup-restore-pdns.sh | 48 ++------------- bashup.sh | 125 ++++++++++++++++++++++++++++++++++++++++ 9 files changed, 164 insertions(+), 477 deletions(-) create mode 100755 bashup.sh diff --git a/README.md b/README.md index 2ed7171..7fecdb5 100644 --- a/README.md +++ b/README.md @@ -25,14 +25,14 @@ cd /usr/local/src/ wget https://git.stack-source.com/msb/bashup/archive/master.tar.gz -O bashup.tar.gz tar zxvf bashup.tar.gz cd bashup -cp bashup-*.sh /usr/local/sbin/ -chmod 755 /usr/local/sbin/bashup-*.sh -chown root:root /usr/local/sbin/bashup-*.sh -nano /usr/local/etc/bashup.cnf +cp bashup*.sh /usr/local/sbin/ +chmod 755 /usr/local/sbin/bashup*.sh +chown root:root /usr/local/sbin/bashup*.sh +nano /usr/local/sbing/bashup.cnf crontab -e ``` -The "nano /usr/local/etc/bashup.cnf" command is optional. Do this if you need to override any of the settings found at the top of the various bashup scripts. +The "nano /usr/local/sbin/bashup.cnf" command is optional. Do this if you need to override any of the configurable settings found at the top of the script. For the crontab add an entry for each of the "backup" scripts that you'd like to run. For example, to back up files at 3:01 am every day add this crontab: diff --git a/bashup-backup-files.sh b/bashup-backup-files.sh index e08d6d1..3f6868c 100755 --- a/bashup-backup-files.sh +++ b/bashup-backup-files.sh @@ -4,99 +4,11 @@ # https://git.stack-source.com/msb/bashup # MIT License Copyright (c) 2021 Matthew Saunders Brown -# retention vars -retention_years=0; -retention_months=3; -retention_weeks=5; -retention_days=7; -# backup storage directory -backup_storage_dir='/mnt/backups'; -# directories to be backed up -backup_dirs=('/etc' '/home' '/srv' '/root' '/usr/local' '/var/www'); +# load include file +source $(dirname $0)/bashup.sh -# check for local config, which can be used to override any of the above -if [[ -f /usr/local/etc/bashup.cnf ]]; then - source /usr/local/etc/bashup.cnf -fi - -# require root -if [ "${EUID}" -ne 0 ]; then - echo "This script must be run as root" - exit 1 -fi - -if [ ! -d $backup_storage_dir ]; then - echo "ERROR: Backup storage dir ($backup_storage_dir) does not exist." - exit 1 -fi - -# check if backup_storage_dir is a mount in fstab -grep -qs " $backup_storage_dir " /etc/fstab -if [ $? -eq 0 ]; then - # check if backup_storage_dir is already mounted - grep -qs " $backup_storage_dir " /proc/mounts - if [ $? -ne 0 ]; then - # attempt to mount backups - mount $backup_storage_dir - # re-check for backups mount - grep -qs " $backup_storage_dir " /proc/mounts - if [ $? -ne 0 ]; then - echo "ERROR: failed to mount $backup_storage_dir" - exit 1 - fi - fi -fi - -# set more vars based on above settings -today=$(date +%Y%m%d) -existing_backups=($(ls $backup_storage_dir|grep -v lost+found)) -# remove today from existing backups, if it exists. we do other checks later to avoid re-doing backups -if [[ " ${existing_backups[@]} " =~ " ${today} " ]]; then - unset 'existing_backups[-1]'; -fi - -# create retention array -declare -a retention_array - -# set retention days -if [ $retention_days -gt 0 ]; then - i="0" - while [ $i -lt $retention_days ]; do - DATE=`date --date="$i day ago" +%Y%m%d` - retention_array[$DATE]="$DATE" - i=$[$i+1] - done -fi - -# set retention weeks -if [ $retention_weeks -gt 0 ]; then - i="0" - while [ $i -lt $retention_weeks ]; do - i=$[$i+1] - DATE=`date --date="sunday - $i week" +%Y%m%d` - retention_array[$DATE]="$DATE" - done -fi - -# set retention months -if [ $retention_months -gt 0 ]; then - i="0" - while [ $i -lt $retention_months ]; do - DATE=`date --date="$i month ago" +%Y%m01` - retention_array[$DATE]="$DATE" - i=$[$i+1] - done -fi - -# set retention years -if [ $retention_years -gt 0 ]; then - i="0" - while [ $i -lt $retention_years ]; do - DATE=`date --date="$i year ago" +%Y0101` - retention_array[$DATE]="$DATE" - i=$[$i+1] - done -fi +bashup::set_existing_backups +bashup::set_retention_array # create backup for today if [[ " ${retention_array[@]} " =~ " ${today} " ]]; then @@ -180,11 +92,7 @@ for existing_backup in "${existing_backups[@]}"; do done -# check if backup_storage_dir is mounted and unmount if so -grep -qs " $backup_storage_dir " /proc/mounts -if [ $? -eq 0 ]; then - umount $backup_storage_dir -fi +bashup::unmount_storage_dir exit 0 diff --git a/bashup-backup-mysql.sh b/bashup-backup-mysql.sh index 065e8c6..b1b2a67 100755 --- a/bashup-backup-mysql.sh +++ b/bashup-backup-mysql.sh @@ -4,103 +4,11 @@ # https://git.stack-source.com/msb/bashup # MIT License Copyright (c) 2021 Matthew Saunders Brown -# retention vars -retention_years=0; -retention_months=3; -retention_weeks=5; -retention_days=7; -# backup storage directory -backup_storage_dir='/mnt/backups'; -# mysql config file that contains 'host' 'user' 'password' vars -defaults_extra_file='/etc/mysql/debian.cnf'; -# list of databases to skip -exclusions=('information_schema' 'performance_schema' 'sys' 'wsrep'); +# load include file +source $(dirname $0)/bashup.sh -# check for local config, which can be used to override any of the above -if [[ -f /usr/local/etc/bashup.cnf ]]; then - source /usr/local/etc/bashup.cnf -fi - -# require root -if [ "${EUID}" -ne 0 ]; then - echo "This script must be run as root" - exit 1 -fi - -if [ ! -d $backup_storage_dir ]; then - echo "ERROR: Backup storage dir ($backup_storage_dir) does not exist." - exit 1 -fi - -# check if backup_storage_dir is a mount in fstab -grep -qs " $backup_storage_dir " /etc/fstab -if [ $? -eq 0 ]; then - # check if backup_storage_dir is already mounted - grep -qs " $backup_storage_dir " /proc/mounts - if [ $? -ne 0 ]; then - # attempt to mount backups - mount $backup_storage_dir - # re-check for backups mount - grep -qs " $backup_storage_dir " /proc/mounts - if [ $? -ne 0 ]; then - echo "ERROR: failed to mount $backup_storage_dir" - exit 1 - fi - fi -fi - -# get todays date (backup dir name) -today=$(date +%Y%m%d) - -# get list of existing backups -existing_backups=($(ls $backup_storage_dir|grep -v lost+found)) -# remove today from existing backups, if it exists. we do other checks later to avoid re-doing backups -if [[ " ${existing_backups[@]} " =~ " ${today} " ]]; then - unset 'existing_backups[-1]'; -fi - -# create retention array -declare -a retention_array - -# set retention days -if [ $retention_days -gt 0 ]; then - i="0" - while [ $i -lt $retention_days ]; do - DATE=`date --date="$i day ago" +%Y%m%d` - retention_array[$DATE]="$DATE" - i=$[$i+1] - done -fi - -# set retention weeks -if [ $retention_weeks -gt 0 ]; then - i="0" - while [ $i -lt $retention_weeks ]; do - i=$[$i+1] - DATE=`date --date="sunday - $i week" +%Y%m%d` - retention_array[$DATE]="$DATE" - done -fi - -# set retention months -if [ $retention_months -gt 0 ]; then - i="0" - while [ $i -lt $retention_months ]; do - DATE=`date --date="$i month ago" +%Y%m01` - retention_array[$DATE]="$DATE" - i=$[$i+1] - done -fi - -# set retention years -if [ $retention_years -gt 0 ]; then - i="0" - while [ $i -lt $retention_years ]; do - DATE=`date --date="$i year ago" +%Y0101` - retention_array[$DATE]="$DATE" - i=$[$i+1] - done -fi +bashup::set_existing_backups +bashup::set_retention_array # create backup for today if [[ " ${retention_array[@]} " =~ " ${today} " ]]; then @@ -162,10 +70,6 @@ for existing_backup in "${existing_backups[@]}"; do done -# check if backup_storage_dir is mounted and unmount if so -grep -qs " $backup_storage_dir " /proc/mounts -if [ $? -eq 0 ]; then - umount $backup_storage_dir -fi +bashup::unmount_storage_dir -exit 0; +exit 0 diff --git a/bashup-backup-pdns.sh b/bashup-backup-pdns.sh index 2fe5842..211a64a 100755 --- a/bashup-backup-pdns.sh +++ b/bashup-backup-pdns.sh @@ -4,99 +4,11 @@ # https://git.stack-source.com/msb/bashup # MIT License Copyright (c) 2021 Matthew Saunders Brown -# retention vars -retention_years=0; -retention_months=3; -retention_weeks=5; -retention_days=7; -# backup storage directory -backup_storage_dir='/mnt/backups'; +# load include file +source $(dirname $0)/bashup.sh -# check for local config, which can be used to override any of the above -if [[ -f /usr/local/etc/bashup.cnf ]]; then - source /usr/local/etc/bashup.cnf -fi - -# require root -if [ "${EUID}" -ne 0 ]; then - echo "This script must be run as root" - exit 1 -fi - -if [ ! -d $backup_storage_dir ]; then - echo "ERROR: Backup storage dir ($backup_storage_dir) does not exist." - exit 1 -fi - -# check if backup_storage_dir is a mount in fstab -grep -qs " $backup_storage_dir " /etc/fstab -if [ $? -eq 0 ]; then - # check if backup_storage_dir is already mounted - grep -qs " $backup_storage_dir " /proc/mounts - if [ $? -ne 0 ]; then - # attempt to mount backups - mount $backup_storage_dir - # re-check for backups mount - grep -qs " $backup_storage_dir " /proc/mounts - if [ $? -ne 0 ]; then - echo "ERROR: failed to mount $backup_storage_dir" - exit 1 - fi - fi -fi - -# get todays date (backup dir name) -today=$(date +%Y%m%d) - -# get list of existing backups -existing_backups=($(ls $backup_storage_dir|grep -v lost+found)) -# remove today from existing backups, if it exists. we do other checks later to avoid re-doing backups -if [[ " ${existing_backups[@]} " =~ " ${today} " ]]; then - unset 'existing_backups[-1]'; -fi - -# create retention array -declare -a retention_array - -# set retention days -if [ $retention_days -gt 0 ]; then - i="0" - while [ $i -lt $retention_days ]; do - DATE=`date --date="$i day ago" +%Y%m%d` - retention_array[$DATE]="$DATE" - i=$[$i+1] - done -fi - -# set retention weeks -if [ $retention_weeks -gt 0 ]; then - i="0" - while [ $i -lt $retention_weeks ]; do - i=$[$i+1] - DATE=`date --date="sunday - $i week" +%Y%m%d` - retention_array[$DATE]="$DATE" - done -fi - -# set retention months -if [ $retention_months -gt 0 ]; then - i="0" - while [ $i -lt $retention_months ]; do - DATE=`date --date="$i month ago" +%Y%m01` - retention_array[$DATE]="$DATE" - i=$[$i+1] - done -fi - -# set retention years -if [ $retention_years -gt 0 ]; then - i="0" - while [ $i -lt $retention_years ]; do - DATE=`date --date="$i year ago" +%Y0101` - retention_array[$DATE]="$DATE" - i=$[$i+1] - done -fi +bashup::set_existing_backups +bashup::set_retention_array # create backup for today if [[ " ${retention_array[@]} " =~ " ${today} " ]]; then @@ -151,10 +63,6 @@ for existing_backup in "${existing_backups[@]}"; do done -# check if backup_storage_dir is mounted and unmount if so -grep -qs " $backup_storage_dir " /proc/mounts -if [ $? -eq 0 ]; then - umount $backup_storage_dir -fi +bashup::unmount_storage_dir -exit 0; +exit 0 diff --git a/bashup-list-backups.sh b/bashup-list-backups.sh index e8cea65..aaa8188 100755 --- a/bashup-list-backups.sh +++ b/bashup-list-backups.sh @@ -4,21 +4,8 @@ # https://git.stack-source.com/msb/bashup # MIT License Copyright (c) 2021 Matthew Saunders Brown -# backups are stored here -backup_storage_dir='/mnt/backups'; -# directories that are backed up as part of files -backup_dirs=('/etc' '/home' '/srv' '/root' '/usr/local' '/var/www'); - -# check for local config, which can be used to override any of the above -if [[ -f /usr/local/etc/bashup.cnf ]]; then - source /usr/local/etc/bashup.cnf -fi - -# require root -if [ "${EUID}" -ne 0 ]; then - echo "This script must be run as root" - exit 1 -fi +# load include file +source $(dirname $0)/bashup.sh help() { @@ -64,29 +51,6 @@ while getopts "b:c:h" opt; do esac done - -if [ ! -d $backup_storage_dir ]; then - echo "ERROR: Backup storage dir ($backup_storage_dir) does not exist." - exit 1 -fi - -# check if backup_storage_dir is a mount in fstab -grep -qs " $backup_storage_dir " /etc/fstab -if [ $? -eq 0 ]; then - # check if backup_storage_dir is already mounted - grep -qs " $backup_storage_dir " /proc/mounts - if [ $? -ne 0 ]; then - # attempt to mount backups - mount $backup_storage_dir - # re-check for backups mount - grep -qs " $backup_storage_dir " /proc/mounts - if [ $? -ne 0 ]; then - echo "ERROR: failed to mount $backup_storage_dir" - exit 1 - fi - fi -fi - if [ ! -z "$backup" ]; then if [ -d "$backup_storage_dir/$backup" ]; then if [ ! -z "$category" ]; then @@ -131,10 +95,6 @@ else ls -1 $backup_storage_dir | grep -v lost+found fi -# check if backup_storage_dir is mounted and unmount if so -grep -qs " $backup_storage_dir " /proc/mounts -if [ $? -eq 0 ]; then - umount $backup_storage_dir -fi +bashup::unmount_storage_dir exit 0 diff --git a/bashup-restore-files.sh b/bashup-restore-files.sh index c16f672..acc3d35 100755 --- a/bashup-restore-files.sh +++ b/bashup-restore-files.sh @@ -4,21 +4,8 @@ # https://git.stack-source.com/msb/bashup # MIT License Copyright (c) 2021 Matthew Saunders Brown -# backup storage directory -backup_storage_dir='/mnt/backups'; -# directories to be backed up -backup_dirs=('/etc' '/home' '/srv' '/root' '/usr/local' '/var/www'); - -# check for local config, which can be used to override any of the above -if [[ -f /usr/local/etc/bashup.cnf ]]; then - source /usr/local/etc/bashup.cnf -fi - -# require root -if [ "${EUID}" -ne 0 ]; then - echo "This script must be run as root" - exit 1 -fi +# load include file +source $(dirname $0)/bashup.sh help() { @@ -61,30 +48,7 @@ while getopts "b:p:h" opt; do esac done -if [ ! -d $backup_storage_dir ]; then - echo "ERROR: Backup storage dir ($backup_storage_dir) does not exist." - exit 1 -fi - -# check if backup_storage_dir is a mount in fstab -grep -qs " $backup_storage_dir " /etc/fstab -if [ $? -eq 0 ]; then - # check if backup_storage_dir is already mounted - grep -qs " $backup_storage_dir " /proc/mounts - if [ $? -ne 0 ]; then - # attempt to mount backups - mount $backup_storage_dir - # re-check for backups mount - grep -qs " $backup_storage_dir " /proc/mounts - if [ $? -ne 0 ]; then - echo "ERROR: failed to mount $backup_storage_dir" - exit 1 - fi - fi -fi - -# get list of backups (dates) -existing_backups=($(ls $backup_storage_dir|grep -v lost+found)) +bashup::set_existing_backups # prompt if backup was not set on command line if [ -z "$backup" ] ; then @@ -164,10 +128,6 @@ fi "To restore $pathtorestore from $backup run this command:" echo "/usr/bin/rsync -vn --archive --numeric-ids --one-file-system --delete $pathtobackup $pathtorestore" -# check if backup_storage_dir is mounted and unmount if so -/usr/bin/grep -qs " $backup_storage_dir " /proc/mounts -if [ $? -eq 0 ]; then - /usr/bin/umount $backup_storage_dir -fi +bashup::unmount_storage_dir exit 0 diff --git a/bashup-restore-mysql.sh b/bashup-restore-mysql.sh index 671f342..b645b16 100755 --- a/bashup-restore-mysql.sh +++ b/bashup-restore-mysql.sh @@ -4,21 +4,8 @@ # https://git.stack-source.com/msb/bashup # MIT License Copyright (c) 2021 Matthew Saunders Brown -# backup directory -backup_storage_dir='/mnt/backups'; -# config file that contains [client] config with 'host' 'user' 'password' settings -defaults_extra_file='/etc/mysql/debian.cnf'; - -# check for local config, which can be used to override any of the above -if [[ -f /usr/local/etc/bashup.cnf ]]; then - source /usr/local/etc/bashup.cnf -fi - -# require root -if [ "${EUID}" -ne 0 ]; then - echo "This script must be run as root" - exit 1 -fi +# load include file +source $(dirname $0)/bashup.sh help() { @@ -61,30 +48,7 @@ while getopts "b:d:h" opt; do esac done -if [ ! -d $backup_storage_dir ]; then - echo "ERROR: Backup storage dir ($backup_storage_dir) does not exist." - exit 1 -fi - -# check if backup_storage_dir is a mount in fstab -grep -qs " $backup_storage_dir " /etc/fstab -if [ $? -eq 0 ]; then - # check if backup_storage_dir is already mounted - grep -qs " $backup_storage_dir " /proc/mounts - if [ $? -ne 0 ]; then - # attempt to mount backups - mount $backup_storage_dir - # re-check for backups mount - grep -qs " $backup_storage_dir " /proc/mounts - if [ $? -ne 0 ]; then - echo "ERROR: failed to mount $backup_storage_dir" - exit 1 - fi - fi -fi - -# get list of backups (dates) -existing_backups=($(ls $backup_storage_dir|grep -v lost+found)) +bashup::set_existing_backups # prompt if backup was not set on command line if [ -z "$backup" ] ; then @@ -149,10 +113,6 @@ else exit 1 fi -# check if backup_storage_dir is mounted and unmount if so -grep -qs " $backup_storage_dir " /proc/mounts -if [ $? -eq 0 ]; then - umount $backup_storage_dir -fi +bashup::unmount_storage_dir -exit +exit 0 diff --git a/bashup-restore-pdns.sh b/bashup-restore-pdns.sh index c775b2a..286bd60 100755 --- a/bashup-restore-pdns.sh +++ b/bashup-restore-pdns.sh @@ -4,19 +4,8 @@ # https://git.stack-source.com/msb/bashup # MIT License Copyright (c) 2021 Matthew Saunders Brown -# backup directory -backup_storage_dir='/mnt/backups'; - -# check for local config, which can be used to override any of the above -if [[ -f /usr/local/etc/bashup.cnf ]]; then - source /usr/local/etc/bashup.cnf -fi - -# require root -if [ "${EUID}" -ne 0 ]; then - echo "This script must be run as root" - exit 1 -fi +# load include file +source $(dirname $0)/bashup.sh help() { @@ -59,30 +48,7 @@ while getopts "b:z:h" opt; do esac done -if [ ! -d $backup_storage_dir ]; then - echo "ERROR: Backup storage dir ($backup_storage_dir) does not exist." - exit 1 -fi - -# check if backup_storage_dir is a mount in fstab -grep -qs " $backup_storage_dir " /etc/fstab -if [ $? -eq 0 ]; then - # check if backup_storage_dir is already mounted - grep -qs " $backup_storage_dir " /proc/mounts - if [ $? -ne 0 ]; then - # attempt to mount backups - mount $backup_storage_dir - # re-check for backups mount - grep -qs " $backup_storage_dir " /proc/mounts - if [ $? -ne 0 ]; then - echo "ERROR: failed to mount $backup_storage_dir" - exit 1 - fi - fi -fi - -# get list of backups (dates) -existing_backups=($(ls $backup_storage_dir|grep -v lost+found)) +bashup::set_existing_backups # prompt if backup was not set on command line if [ -z "$backup" ] ; then @@ -147,10 +113,6 @@ else exit 1 fi -# check if backup_storage_dir is mounted and unmount if so -grep -qs " $backup_storage_dir " /proc/mounts -if [ $? -eq 0 ]; then - umount $backup_storage_dir -fi +bashup::unmount_storage_dir -exit +exit 0 diff --git a/bashup.sh b/bashup.sh new file mode 100755 index 0000000..d2dfa37 --- /dev/null +++ b/bashup.sh @@ -0,0 +1,125 @@ +#!/bin/bash +# +# Bashup - A set of bash scripts for managing backups. +# https://git.stack-source.com/msb/bashup +# MIT License Copyright (c) 2021 Matthew Saunders Brown + +# +# begin configurable vars +# + +# retention vars +retention_years=0; +retention_months=3; +retention_weeks=5; +retention_days=7; + +# backup storage directory +backup_storage_dir='/mnt/backups'; + +# directories to be backed up by files +backup_dirs=('/etc' '/home' '/srv' '/root' '/usr/local' '/var/www'); + +# mysql config file that contains 'host' 'user' 'password' vars +defaults_extra_file='/etc/mysql/debian.cnf'; + +# list of mysql databases to skip +exclusions=('information_schema' 'performance_schema' 'sys' 'wsrep'); + +# +# end configurable vars +# + +# must be root, attempt sudo if need be +if [ "${EUID}" -ne 0 ]; then + exec sudo -u root --shell /bin/bash $0 $@ +fi + +# check for backup storage directory and mount if need be +if [ -d $backup_storage_dir ]; then + # check if backup_storage_dir is a mount in fstab + grep -qs " $backup_storage_dir " /etc/fstab + if [ $? -eq 0 ]; then + # check if backup_storage_dir is already mounted + grep -qs " $backup_storage_dir " /proc/mounts + if [ $? -ne 0 ]; then + # attempt to mount backups + mount $backup_storage_dir + # re-check for backups mount + grep -qs " $backup_storage_dir " /proc/mounts + if [ $? -ne 0 ]; then + echo "ERROR: failed to mount $backup_storage_dir" + exit 1 + fi + fi + fi +else + echo "ERROR: Backup storage dir ($backup_storage_dir) does not exist." + exit 1 +fi + +# get todays date (backup dir name) +today=$(date +%Y%m%d) + +# set existing_backups array +existing_backups=($(ls $backup_storage_dir|grep -v lost+found)) +# if script is a *-backup-* script remove today from existing backups, if it exists. we do other checks avoid re-doing backups +if [[ "$0" == *"-backup-"* ]];then + if [[ " ${existing_backups[@]} " =~ " ${today} " ]]; then + unset 'existing_backups[-1]'; + fi +fi + +function bashup::set_retention_array () { + + declare -a retention_array + + # set retention days + if [ $retention_days -gt 0 ]; then + i="0" + while [ $i -lt $retention_days ]; do + DATE=`date --date="$i day ago" +%Y%m%d` + retention_array[$DATE]="$DATE" + i=$[$i+1] + done + fi + + # set retention weeks + if [ $retention_weeks -gt 0 ]; then + i="0" + while [ $i -lt $retention_weeks ]; do + i=$[$i+1] + DATE=`date --date="sunday - $i week" +%Y%m%d` + retention_array[$DATE]="$DATE" + done + fi + + # set retention months + if [ $retention_months -gt 0 ]; then + i="0" + while [ $i -lt $retention_months ]; do + DATE=`date --date="$i month ago" +%Y%m01` + retention_array[$DATE]="$DATE" + i=$[$i+1] + done + fi + + # set retention years + if [ $retention_years -gt 0 ]; then + i="0" + while [ $i -lt $retention_years ]; do + DATE=`date --date="$i year ago" +%Y0101` + retention_array[$DATE]="$DATE" + i=$[$i+1] + done + fi + +} + +function bashup::unmount_storage_dir () { + # check if backup_storage_dir is mounted and unmount if so + grep -qs " $backup_storage_dir " /proc/mounts + if [ $? -eq 0 ]; then + umount $backup_storage_dir + fi +}