Commit 195c93d1 authored by Michael Iseard's avatar Michael Iseard
Browse files

check_result now accepts exit code argument

parent 1d1561b4
...@@ -28,41 +28,44 @@ fi ...@@ -28,41 +28,44 @@ fi
function check_result() { function check_result() {
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo $done echo "$done"
else else
echo "$fail(exit code: $?)" echo "$fail(exit code: $?)"
exit 1 if [ "$1" -gt 0 ]; then
echo "exiting..."
exit "$1"
fi
fi fi
} }
if [[ ! -z "$IM_NFS_MOUNT_POINT" || "$IM_NFS_SOURCE" ]]; then if [[ ! -z "$IM_NFS_MOUNT_POINT" || "$IM_NFS_SOURCE" ]]; then
echo -n 'Mounting NFS.......'$dots echo -n 'Mounting NFS.......'$dots
sudo mount $IM_NFS_SOURCE $IM_BACKUP_DESTINATION sudo mount $IM_NFS_SOURCE $IM_BACKUP_DESTINATION
check_result check_result 1
fi fi
if [ ! -z "$containers" ]; then if [ ! -z "$containers" ]; then
echo -n 'Stopping containers'$dots echo -n 'Stopping containers'$dots
docker stop $containers > /dev/null 2>&1 docker stop $containers > /dev/null 2>&1
check_result check_result 0
fi fi
echo -n 'Sending backup.....'$dots echo -n 'Sending backup.....'$dots
borg create $IM_BACKUP_DESTINATION::$name $IM_BACKUP_SOURCE borg create $IM_BACKUP_DESTINATION::$name $IM_BACKUP_SOURCE
check_result check_result 0
echo -n 'Pruning backups....'$dots echo -n 'Pruning backups....'$dots
borg prune -sv -d7 -w4 -m12 --show-rc $IM_BACKUP_DESTINATION > /dev/null 2>&1 borg prune -sv -d7 -w4 -m12 --show-rc $IM_BACKUP_DESTINATION > /dev/null 2>&1
check_result check_result 0
if [[ ! -z "$IM_NFS_MOUNT_POINT" || "$IM_NFS_SOURCE" ]]; then if [[ ! -z "$IM_NFS_MOUNT_POINT" || "$IM_NFS_SOURCE" ]]; then
echo -n 'Unmounting backup..'$dots echo -n 'Unmounting backup..'$dots
sudo umount /nfs/BACKUP1/ sudo umount /nfs/BACKUP1/
check_result check_result 0
fi fi
if [ ! -z "$containers" ]; then if [ ! -z "$containers" ]; then
echo -n 'Starting containers'$dots echo -n 'Starting containers'$dots
docker start $containers > /dev/null 2>&1 docker start $containers > /dev/null 2>&1
check_result check_result 1
fi fi
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment