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
function check_result() {
if [ $? -eq 0 ]; then
echo $done
echo "$done"
else
echo "$fail(exit code: $?)"
exit 1
if [ "$1" -gt 0 ]; then
echo "exiting..."
exit "$1"
fi
fi
}
if [[ ! -z "$IM_NFS_MOUNT_POINT" || "$IM_NFS_SOURCE" ]]; then
echo -n 'Mounting NFS.......'$dots
sudo mount $IM_NFS_SOURCE $IM_BACKUP_DESTINATION
check_result
check_result 1
fi
if [ ! -z "$containers" ]; then
echo -n 'Stopping containers'$dots
docker stop $containers > /dev/null 2>&1
check_result
check_result 0
fi
echo -n 'Sending backup.....'$dots
borg create $IM_BACKUP_DESTINATION::$name $IM_BACKUP_SOURCE
check_result
check_result 0
echo -n 'Pruning backups....'$dots
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
echo -n 'Unmounting backup..'$dots
sudo umount /nfs/BACKUP1/
check_result
check_result 0
fi
if [ ! -z "$containers" ]; then
echo -n 'Starting containers'$dots
docker start $containers > /dev/null 2>&1
check_result
check_result 1
fi
\ No newline at end of file
Markdown is supported
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