various improvements
[distro-setup] / btrbk-run
index e30c9c3dd3667d259a46e560773890e3919dd9a9..3ec2221d1238b22ab596f71b47e90f54a68365c1 100644 (file)
--- a/btrbk-run
+++ b/btrbk-run
@@ -150,9 +150,18 @@ while true; do
   esac
 done
 
-# usefull commands are resume and archive
+# only tested commands are resume and archive
 cmd_arg=${1:-run}
 
+case $cmd_arg in
+  run|resume|archive) : ;;
+  *) die "untested command arg" ;;
+esac
+
+if (( $# > 1 )); then
+  die: "only 1 nonoption arg is supported"
+fi
+
 if [[ -v targets && $source ]]; then
   die "error: -t and -s are mutually exclusive"
 fi
@@ -247,7 +256,14 @@ fi
 
 echo "mountpoints: ${mountpoints[*]}"
 
+##### end command line parsing ########
 
+if [[ $source ]]; then
+  if [[ $(ssh $source systemctl is-active btrbk.service) != inactive ]]; then
+    echo "$0: error: cron btrbk is running on source. exiting out of caution"
+    exit 1
+  fi
+fi
 
 # pull_reexec stops us from getting into an infinite loop if there is some
 # kind of weird problem
@@ -270,7 +286,6 @@ if ! $pull_reexec && [[ $source ]] && $pulla ; then
 fi
 
 
-##### end command line parsing ########