From 49168edafb41d3f6045f8b35c8c7d9c04cec3320 Mon Sep 17 00:00:00 2001 From: redxef Date: Thu, 8 Jun 2023 17:49:44 +0200 Subject: [PATCH] Additionally to backing up a docker volume, allow to run in docker. --- tarback/docker.sh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/tarback/docker.sh b/tarback/docker.sh index 9e66adf..eb8d02a 100644 --- a/tarback/docker.sh +++ b/tarback/docker.sh @@ -1,7 +1,25 @@ #!/bin/sh -_tarback_plugin_docker_cmd='docker run -i --rm --workdir=/mnt --volume="$1":/mnt/"$1" alpine ' -TARBACK_TAR_CREATE_COMMAND="$_tarback_plugin_docker_cmd "'tar c -C "/mnt/$1" .' -TARBACK_TAR_EXTRACT_COMMAND="$_tarback_plugin_docker_cmd "'tar x -C "/mnt/$1"' +_tarback_plugin_docker_use_container=false + +short_options='c' +while getopts "$short_options" arg; do + case "$arg" in + c) + _tarback_plugin_docker_use_container="$OPTARG" + ;; + esac +done + +if "$_tarback_plugin_docker_use_container"; then + _tarback_plugin_docker_cmd='docker exec -i "$1" ' + TARBACK_TAR_CREATE_COMMAND="$_tarback_plugin_docker_cmd $TARBACK_TAR_CREATE_COMMAND" + TARBACK_TAR_EXTRACT_COMMAND="$_tarback_plugin_docker_cmd $TARBACK_TAR_EXTRACT_COMMAND" +else + _tarback_plugin_docker_cmd='docker run -i --rm --workdir=/mnt --volume="$1":/mnt/"$1" alpine ' + + TARBACK_TAR_CREATE_COMMAND="$_tarback_plugin_docker_cmd $(echo "$TARBACK_TAR_CREATE_COMMAND" | sed 's_$1_/mnt/$1_g')" + TARBACK_TAR_EXTRACT_COMMAND="$_tarback_plugin_docker_cmd $(echo "$TARBACK_TAR_EXTRACT_COMMAND" | sed 's_$1_/mnt/$1_g')" +fi TARBACK_TAR_CREATE_USE_ALT_COMMAND=false TARBACK_TAR_EXTRACT_USE_ALT_COMMAND=false