Make alternative tar command settable.
This commit is contained in:
parent
cbd8e4cb09
commit
dfb3696910
2 changed files with 12 additions and 6 deletions
12
tarback.sh
12
tarback.sh
|
@ -12,10 +12,12 @@ TARBACK_TRANSFORM_REMOTE_ARGUMENT_COMMAND_DEFAULT=
|
||||||
TARBACK_TAR_CREATE_COMMAND_DEFAULT='tar c -C "$1" .'
|
TARBACK_TAR_CREATE_COMMAND_DEFAULT='tar c -C "$1" .'
|
||||||
# shellcheck disable=SC2016 # disable variable not expanding hint
|
# shellcheck disable=SC2016 # disable variable not expanding hint
|
||||||
TARBACK_TAR_CREATE_COMMAND_FILE_DEFAULT='tar c -C "$(dirname "$1")" "$(basename "$1")"'
|
TARBACK_TAR_CREATE_COMMAND_FILE_DEFAULT='tar c -C "$(dirname "$1")" "$(basename "$1")"'
|
||||||
|
TARBACK_TAR_CREATE_USE_ALT_COMMAND_DEFAULT='[ ! -d "$1" ]'
|
||||||
# shellcheck disable=SC2016 # disable variable not expanding hint
|
# shellcheck disable=SC2016 # disable variable not expanding hint
|
||||||
TARBACK_TAR_EXTRACT_COMMAND_DEFAULT='tar x -C "$1"'
|
TARBACK_TAR_EXTRACT_COMMAND_DEFAULT='tar x -C "$1"'
|
||||||
# shellcheck disable=SC2016 # disable variable not expanding hint
|
# shellcheck disable=SC2016 # disable variable not expanding hint
|
||||||
TARBACK_TAR_EXTRACT_COMMAND_FILE_DEFAULT='tar x -C "$(dirname "$1")"'
|
TARBACK_TAR_EXTRACT_COMMAND_FILE_DEFAULT='tar x -C "$(dirname "$1")"'
|
||||||
|
TARBACK_TAR_EXTRACT_USE_ALT_COMMAND_DEFAULT='[ ! -e "$1" ] && [ -d "$(dirname "$1")" ]'
|
||||||
TARBACK_COMPRESSION_DEFAULT='xz'
|
TARBACK_COMPRESSION_DEFAULT='xz'
|
||||||
TARBACK_SPLIT_DEFAULT="split -b $((128*1024*1024)) -"
|
TARBACK_SPLIT_DEFAULT="split -b $((128*1024*1024)) -"
|
||||||
TARBACK_MERGE_DEFAULT='cat'
|
TARBACK_MERGE_DEFAULT='cat'
|
||||||
|
@ -30,8 +32,10 @@ TARBACK_TRANSFORM_REMOTE_COMMAND="${TARBACK_TRANSFORM_REMOTE_COMMAND:-$TARBACK_T
|
||||||
TARBACK_TRANSFORM_REMOTE_ARGUMENT_COMMAND="${TARBACK_TRANSFORM_REMOTE_ARGUMENT_COMMAND:-$TARBACK_TRANSFORM_REMOTE_ARGUMENT_COMMAND_DEFAULT}"
|
TARBACK_TRANSFORM_REMOTE_ARGUMENT_COMMAND="${TARBACK_TRANSFORM_REMOTE_ARGUMENT_COMMAND:-$TARBACK_TRANSFORM_REMOTE_ARGUMENT_COMMAND_DEFAULT}"
|
||||||
TARBACK_TAR_CREATE_COMMAND="${TARBACK_TAR_CREATE_COMMAND:-$TARBACK_TAR_CREATE_COMMAND_DEFAULT}"
|
TARBACK_TAR_CREATE_COMMAND="${TARBACK_TAR_CREATE_COMMAND:-$TARBACK_TAR_CREATE_COMMAND_DEFAULT}"
|
||||||
TARBACK_TAR_CREATE_COMMAND_FILE="${TARBACK_TAR_CREATE_COMMAND_FILE:-$TARBACK_TAR_CREATE_COMMAND_FILE_DEFAULT}"
|
TARBACK_TAR_CREATE_COMMAND_FILE="${TARBACK_TAR_CREATE_COMMAND_FILE:-$TARBACK_TAR_CREATE_COMMAND_FILE_DEFAULT}"
|
||||||
|
TARBACK_TAR_CREATE_USE_ALT_COMMAND="${TARBACK_TAR_CREATE_USE_ALT_COMMAND:-$TARBACK_TAR_CREATE_USE_ALT_COMMAND_DEFAULT}"
|
||||||
TARBACK_TAR_EXTRACT_COMMAND="${TARBACK_TAR_EXTRACT_COMMAND:-$TARBACK_TAR_EXTRACT_COMMAND_DEFAULT}"
|
TARBACK_TAR_EXTRACT_COMMAND="${TARBACK_TAR_EXTRACT_COMMAND:-$TARBACK_TAR_EXTRACT_COMMAND_DEFAULT}"
|
||||||
TARBACK_TAR_EXTRACT_COMMAND_FILE="${TARBACK_TAR_EXTRACT_COMMAND_FILE:-$TARBACK_TAR_EXTRACT_COMMAND_FILE_DEFAULT}"
|
TARBACK_TAR_EXTRACT_COMMAND_FILE="${TARBACK_TAR_EXTRACT_COMMAND_FILE:-$TARBACK_TAR_EXTRACT_COMMAND_FILE_DEFAULT}"
|
||||||
|
TARBACK_TAR_EXTRACT_USE_ALT_COMMAND="${TARBACK_TAR_EXTRACT_USE_ALT_COMMAND:-$TARBACK_TAR_EXTRACT_USE_ALT_COMMAND_DEFAULT}"
|
||||||
TARBACK_COMPRESSION="${TARBACK_COMPRESSION:-$TARBACK_COMPRESSION_DEFAULT}"
|
TARBACK_COMPRESSION="${TARBACK_COMPRESSION:-$TARBACK_COMPRESSION_DEFAULT}"
|
||||||
TARBACK_SPLIT="${TARBACK_SPLIT:-$TARBACK_SPLIT_DEFAULT}"
|
TARBACK_SPLIT="${TARBACK_SPLIT:-$TARBACK_SPLIT_DEFAULT}"
|
||||||
TARBACK_MERGE="${TARBACK_MERGE:-$TARBACK_MERGE_DEFAULT}"
|
TARBACK_MERGE="${TARBACK_MERGE:-$TARBACK_MERGE_DEFAULT}"
|
||||||
|
@ -68,7 +72,7 @@ _create() {
|
||||||
# $2 ... dst
|
# $2 ... dst
|
||||||
src="$1"
|
src="$1"
|
||||||
dst="$(_transform_split_name "$2")"
|
dst="$(_transform_split_name "$2")"
|
||||||
if [ -d "$src" ]; then
|
if ! sh -c "$TARBACK_TAR_CREATE_USE_ALT_COMMAND" - "$src"; then
|
||||||
tarback_tar_create_command="$TARBACK_TAR_CREATE_COMMAND"
|
tarback_tar_create_command="$TARBACK_TAR_CREATE_COMMAND"
|
||||||
else
|
else
|
||||||
tarback_tar_create_command="$TARBACK_TAR_CREATE_COMMAND_FILE"
|
tarback_tar_create_command="$TARBACK_TAR_CREATE_COMMAND_FILE"
|
||||||
|
@ -86,10 +90,10 @@ create() {
|
||||||
_restore() {
|
_restore() {
|
||||||
src="$(_transform_split_name "$1")"
|
src="$(_transform_split_name "$1")"
|
||||||
dst="$2"
|
dst="$2"
|
||||||
if [ ! -e "$dst" ] && [ -d "$(dirname "$dst")" ]; then
|
if ! sh -c "$TARBACK_TAR_EXTRACT_USE_ALT_COMMAND" - "$dst"; then
|
||||||
tarback_tar_extract_command="$TARBACK_TAR_EXTRACT_COMMAND_FILE"
|
|
||||||
else
|
|
||||||
tarback_tar_extract_command="$TARBACK_TAR_EXTRACT_COMMAND"
|
tarback_tar_extract_command="$TARBACK_TAR_EXTRACT_COMMAND"
|
||||||
|
else
|
||||||
|
tarback_tar_extract_command="$TARBACK_TAR_EXTRACT_COMMAND_FILE"
|
||||||
fi
|
fi
|
||||||
tarback_tar_extract_command="$(_transform_remote "$tarback_tar_extract_command")"
|
tarback_tar_extract_command="$(_transform_remote "$tarback_tar_extract_command")"
|
||||||
$TARBACK_MERGE "$src"* \
|
$TARBACK_MERGE "$src"* \
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
_tarback_plugin_docker_cmd='docker run -i --rm --workdir=/mnt --volume="$1":/mnt/"$1" alpine '
|
_tarback_plugin_docker_cmd='docker run -i --rm --workdir=/mnt --volume="$1":/mnt/"$1" alpine '
|
||||||
TARBACK_TAR_CREATE_COMMAND_FILE="$_tarback_plugin_docker_cmd "'tar c -C "/mnt/$1" .'
|
TARBACK_TAR_CREATE_COMMAND="$_tarback_plugin_docker_cmd "'tar c -C "/mnt/$1" .'
|
||||||
TARBACK_TAR_EXTRACT_COMMAND_FILE="$_tarback_plugin_docker_cmd "'tar x -C "/mnt/$1"'
|
TARBACK_TAR_EXTRACT_COMMAND="$_tarback_plugin_docker_cmd "'tar x -C "/mnt/$1"'
|
||||||
|
TARBACK_TAR_CREATE_USE_ALT_COMMAND=false
|
||||||
|
TARBACK_TAR_EXTRACT_USE_ALT_COMMAND=false
|
||||||
|
|
Loading…
Reference in a new issue