Compare commits

..

No commits in common. "47781e8bcf41746d2a84f3716e47b146ac9ebf13" and "c6163da5e4f0cc6587e218944641eb6d9a5faacd" have entirely different histories.

7 changed files with 27 additions and 80 deletions

View file

@ -53,22 +53,14 @@ _="${TARBACK_TAR_EXTRACT_USE_ALT_COMMAND:=$TARBACK_TAR_EXTRACT_USE_ALT_COMMAND_D
_="${TARBACK_COMPRESSION:=$TARBACK_COMPRESSION_DEFAULT}" _="${TARBACK_COMPRESSION:=$TARBACK_COMPRESSION_DEFAULT}"
_="${TARBACK_SPLIT:=$TARBACK_SPLIT_DEFAULT}" _="${TARBACK_SPLIT:=$TARBACK_SPLIT_DEFAULT}"
_="${TARBACK_MERGE:=$TARBACK_MERGE_DEFAULT}" _="${TARBACK_MERGE:=$TARBACK_MERGE_DEFAULT}"
_="${TARBACK_EXTENSION:=tar.$TARBACK_COMPRESSION}"
_transform_split_name() { _transform_split_name() {
case "$1" in
*"$TARBACK_EXTENSION")
n="$1"
;;
*)
n="$1.$TARBACK_EXTENSION"
;;
esac
command_name="$(echo "$TARBACK_SPLIT" | awk '{print $1}')" command_name="$(echo "$TARBACK_SPLIT" | awk '{print $1}')"
if echo "$command_name" | grep -q 'split'; then if echo "$command_name" | grep -q 'split'; then
n="$n.part" echo "$1.part"
else
echo "$1"
fi fi
echo "$n"
} }
_transform_remote() { _transform_remote() {
@ -125,10 +117,10 @@ restore() {
_restore "$@" _restore "$@"
} }
short_options='P:' short_options='p:'
while getopts "$short_options" arg; do while getopts "$short_options" arg; do
case "$arg" in case "$arg" in
P) p)
for p in $(echo "$OPTARG" | tr ',' ' '); do for p in $(echo "$OPTARG" | tr ',' ' '); do
# source plugin file(s) # source plugin file(s)
sourced=false sourced=false

View file

@ -1,24 +1,7 @@
#!/bin/sh #!/bin/sh
_tarback_plugin_docker_use_container= _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" .'
short_options='c:' TARBACK_TAR_EXTRACT_COMMAND="$_tarback_plugin_docker_cmd "'tar x -C "/mnt/$1"'
while getopts "$short_options" arg; do
case "$arg" in
c)
_tarback_plugin_docker_use_container="$OPTARG"
;;
esac
done
if [ -n "$_tarback_plugin_docker_use_container" ]; then
_tarback_plugin_docker_cmd="docker exec -i '$_tarback_plugin_docker_use_container' "
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_CREATE_USE_ALT_COMMAND=false
TARBACK_TAR_EXTRACT_USE_ALT_COMMAND=false TARBACK_TAR_EXTRACT_USE_ALT_COMMAND=false

View file

@ -1,32 +0,0 @@
#!/bin/sh
_tarback_plugin_postgres_host=
_tarback_plugin_postgres_port=
_tarback_plugin_postgres_user=
short_options='h:p:U:'
while getopts "$short_options" arg; do
case "$arg" in
h)
_tarback_plugin_postgres_host="$OPTARG"
;;
p)
_tarback_plugin_postgres_port="$OPTARG"
;;
U)
_tarback_plugin_postgres_user="$OPTARG"
;;
esac
done
_tarback_plugin_postgres_command=
[ -n "$_tarback_plugin_postgres_host" ] && _tarback_plugin_postgres_command="$_tarback_plugin_postgres_command -h '$_tarback_plugin_postgres_host'"
[ -n "$_tarback_plugin_postgres_port" ] && _tarback_plugin_postgres_command="$_tarback_plugin_postgres_command -p '$_tarback_plugin_postgres_port'"
[ -n "$_tarback_plugin_postgres_user" ] && _tarback_plugin_postgres_command="$_tarback_plugin_postgres_command -U '$_tarback_plugin_postgres_user'"
_tarback_plugin_postgres_create_command="pg_dump $_tarback_plugin_postgres_command "'"$1"'
_tarback_plugin_postgres_extract_command="psql $_tarback_plugin_postgres_command"
TARBACK_TAR_CREATE_COMMAND="$_tarback_plugin_postgres_create_command"
TARBACK_TAR_EXTRACT_COMMAND="$_tarback_plugin_postgres_extract_command"
TARBACK_EXTENSION='xz'
TARBACK_TAR_CREATE_USE_ALT_COMMAND=false
TARBACK_TAR_EXTRACT_USE_ALT_COMMAND=false

View file

@ -18,12 +18,16 @@ _tarback_plugin_ssh_transform_ssh_argument() {
fi fi
} }
short_options='s:' short_options='p:s:'
while getopts "$short_options" arg; do while getopts "$short_options" arg; do
case "$arg" in case "$arg" in
s) s)
TARBACK_REMOTE="$OPTARG" TARBACK_REMOTE="$OPTARG"
;; ;;
*)
echo "unknown option $1" >&2
#exit 1
;;
esac esac
done done

View file

@ -8,24 +8,24 @@ export TARBACK_REMOTE='ssh localhost'
# archive whole directory # archive whole directory
workdir="$(create_directories)" workdir="$(create_directories)"
./tarback.sh -P ssh create "$workdir/source" "$workdir/dest/source.tar.xz" ./tarback.sh -p ssh create "$workdir/source" "$workdir/dest/source.tar.xz"
./tarback.sh -P ssh restore "$workdir/dest/source.tar.xz" "$workdir/restore" ./tarback.sh -p ssh restore "$workdir/dest/source.tar.xz" "$workdir/restore"
diff "$workdir/source" "$workdir/restore" diff "$workdir/source" "$workdir/restore"
rm -rf "$workdir" rm -rf "$workdir"
# archive single file # archive single file
workdir="$(create_directories)" workdir="$(create_directories)"
filename="$(basename "$(find "$workdir/source" -type f)")" filename="$(basename "$(find "$workdir/source" -type f)")"
./tarback.sh -P ssh create "$workdir/source/$filename" "$workdir/dest/source.tar.xz" ./tarback.sh -p ssh create "$workdir/source/$filename" "$workdir/dest/source.tar.xz"
./tarback.sh -P ssh restore "$workdir/dest/source.tar.xz" "$workdir/restore/$filename" ./tarback.sh -p ssh restore "$workdir/dest/source.tar.xz" "$workdir/restore/$filename"
diff "$workdir/source" "$workdir/restore" diff "$workdir/source" "$workdir/restore"
rm -rf "$workdir" rm -rf "$workdir"
# split archive # split archive
workdir="$(create_directories)" workdir="$(create_directories)"
filename="$(basename "$(find "$workdir/source" -type f)")" filename="$(basename "$(find "$workdir/source" -type f)")"
TARBACK_SPLIT="split -b 10 -" ./tarback.sh -P ssh create "$workdir/source/$filename" "$workdir/dest/source.tar.xz" TARBACK_SPLIT="split -b 10 -" ./tarback.sh -p ssh create "$workdir/source/$filename" "$workdir/dest/source.tar.xz"
TARBACK_SPLIT="split -b 10 -" ./tarback.sh -P ssh restore "$workdir/dest/source.tar.xz" "$workdir/restore/$filename" TARBACK_SPLIT="split -b 10 -" ./tarback.sh -p ssh restore "$workdir/dest/source.tar.xz" "$workdir/restore/$filename"
diff "$workdir/source" "$workdir/restore" diff "$workdir/source" "$workdir/restore"
[ "$(ls -1 "$workdir/dest/"*.part* | wc -l)" -gt 1 ] [ "$(ls -1 "$workdir/dest/"*.part* | wc -l)" -gt 1 ]
rm -rf "$workdir" rm -rf "$workdir"

View file

@ -8,10 +8,10 @@ set -eu
workdir="$(create_directories 127)" workdir="$(create_directories 127)"
filename="$(basename "$(find "$workdir/source" -type f)")" filename="$(basename "$(find "$workdir/source" -type f)")"
docker_volume="$(create_docker_volume "$workdir" "$filename")" docker_volume="$(create_docker_volume "$workdir" "$filename")"
./tarback.sh -P docker create "$docker_volume" "$workdir/dest/source.tar.xz" ./tarback.sh -p docker create "$docker_volume" "$workdir/dest/source.tar.xz"
docker volume rm "$docker_volume" 2>/dev/null 1>&2 docker volume rm "$docker_volume" 2>/dev/null 1>&2
docker_volume="$(create_docker_volume)" docker_volume="$(create_docker_volume)"
./tarback.sh -P docker restore "$workdir/dest/source.tar.xz" "$docker_volume" ./tarback.sh -p docker restore "$workdir/dest/source.tar.xz" "$docker_volume"
extract_docker_volume "$docker_volume" "$workdir" "$filename" extract_docker_volume "$docker_volume" "$workdir" "$filename"
diff "$workdir/source" "$workdir/restore" diff "$workdir/source" "$workdir/restore"
docker volume rm "$docker_volume" 2>/dev/null 1>&2 docker volume rm "$docker_volume" 2>/dev/null 1>&2
@ -20,10 +20,10 @@ rm -rf "$workdir"
workdir="$(create_directories 127)" workdir="$(create_directories 127)"
filename="$(basename "$(find "$workdir/source" -type f)")" filename="$(basename "$(find "$workdir/source" -type f)")"
docker_volume="$(create_docker_volume "$workdir" "$filename")" docker_volume="$(create_docker_volume "$workdir" "$filename")"
TARBACK_SPLIT='split -b 10 -' ./tarback.sh -P docker create "$docker_volume" "$workdir/dest/source.tar.xz" TARBACK_SPLIT='split -b 10 -' ./tarback.sh -p docker create "$docker_volume" "$workdir/dest/source.tar.xz"
docker volume rm "$docker_volume" 2>/dev/null 1>&2 docker volume rm "$docker_volume" 2>/dev/null 1>&2
docker_volume="$(create_docker_volume)" docker_volume="$(create_docker_volume)"
TARBACK_SPLIT='split -b 10 -' ./tarback.sh -P docker restore "$workdir/dest/source.tar.xz" "$docker_volume" TARBACK_SPLIT='split -b 10 -' ./tarback.sh -p docker restore "$workdir/dest/source.tar.xz" "$docker_volume"
extract_docker_volume "$docker_volume" "$workdir" "$filename" extract_docker_volume "$docker_volume" "$workdir" "$filename"
diff "$workdir/source" "$workdir/restore" diff "$workdir/source" "$workdir/restore"
docker volume rm "$docker_volume" 2>/dev/null 1>&2 docker volume rm "$docker_volume" 2>/dev/null 1>&2

View file

@ -10,10 +10,10 @@ export TARBACK_REMOTE='ssh localhost'
workdir="$(create_directories 127)" workdir="$(create_directories 127)"
filename="$(basename "$(find "$workdir/source" -type f)")" filename="$(basename "$(find "$workdir/source" -type f)")"
docker_volume="$(create_docker_volume "$workdir" "$filename")" docker_volume="$(create_docker_volume "$workdir" "$filename")"
./tarback.sh -P ssh,docker create "$docker_volume" "$workdir/dest/source.tar.xz" ./tarback.sh -p ssh,docker create "$docker_volume" "$workdir/dest/source.tar.xz"
docker volume rm "$docker_volume" 2>/dev/null 1>&2 docker volume rm "$docker_volume" 2>/dev/null 1>&2
docker_volume="$(create_docker_volume)" docker_volume="$(create_docker_volume)"
./tarback.sh -P ssh,docker restore "$workdir/dest/source.tar.xz" "$docker_volume" ./tarback.sh -p ssh,docker restore "$workdir/dest/source.tar.xz" "$docker_volume"
extract_docker_volume "$docker_volume" "$workdir" "$filename" extract_docker_volume "$docker_volume" "$workdir" "$filename"
diff "$workdir/source" "$workdir/restore" diff "$workdir/source" "$workdir/restore"
docker volume rm "$docker_volume" 2>/dev/null 1>&2 docker volume rm "$docker_volume" 2>/dev/null 1>&2
@ -22,10 +22,10 @@ rm -rf "$workdir"
workdir="$(create_directories 127)" workdir="$(create_directories 127)"
filename="$(basename "$(find "$workdir/source" -type f)")" filename="$(basename "$(find "$workdir/source" -type f)")"
docker_volume="$(create_docker_volume "$workdir" "$filename")" docker_volume="$(create_docker_volume "$workdir" "$filename")"
TARBACK_SPLIT='split -b 10 -' ./tarback.sh -P ssh,docker create "$docker_volume" "$workdir/dest/source.tar.xz" TARBACK_SPLIT='split -b 10 -' ./tarback.sh -p ssh,docker create "$docker_volume" "$workdir/dest/source.tar.xz"
docker volume rm "$docker_volume" 2>/dev/null 1>&2 docker volume rm "$docker_volume" 2>/dev/null 1>&2
docker_volume="$(create_docker_volume)" docker_volume="$(create_docker_volume)"
TARBACK_SPLIT='split -b 10 -' ./tarback.sh -P ssh,docker restore "$workdir/dest/source.tar.xz" "$docker_volume" TARBACK_SPLIT='split -b 10 -' ./tarback.sh -p ssh,docker restore "$workdir/dest/source.tar.xz" "$docker_volume"
extract_docker_volume "$docker_volume" "$workdir" "$filename" extract_docker_volume "$docker_volume" "$workdir" "$filename"
diff "$workdir/source" "$workdir/restore" diff "$workdir/source" "$workdir/restore"
docker volume rm "$docker_volume" 2>/dev/null 1>&2 docker volume rm "$docker_volume" 2>/dev/null 1>&2