From 737ffe31fc73d6c798dd90d90ec879f44e27b60c Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Thu, 28 Jan 2021 20:47:58 +0100 Subject: [PATCH] new: [myc-check-and-launch-backup] new script for checking backup installation Signed-off-by: Valentin Lab --- bin/myc-check-and-launch-backup | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 bin/myc-check-and-launch-backup diff --git a/bin/myc-check-and-launch-backup b/bin/myc-check-and-launch-backup new file mode 100755 index 0000000..8b9bb3d --- /dev/null +++ b/bin/myc-check-and-launch-backup @@ -0,0 +1,30 @@ +#!/bin/bash + +## +## Quick and dirty check launching backup +## + +if ! cron_line=$(docker exec -ti myc_cron_1 cat /etc/cron.d/rsync-backup | grep "\* \* \*"); then + echo "can't find cron_line in cron container." >&2 + exit 1 +fi + +cron_line=${cron_line%|*} +cron_line=${cron_line%"2>&1"*} + +cmd_line="${cron_line#*root}" + +eval "args=($cmd_line)" + +## should be last argument + +docker_cmd=$(echo ${args[@]: -1}) + +if ! [[ "$docker_cmd" == "docker run --rm -e "* ]]; then + echo "docker command found should start with 'docker run'." >&2 + echo "Here's command:" >&2 + echo " $docker_cmd" >&2 + exit 1 +fi + +eval "docker exec -i myc_cron_1 $docker_cmd"