diff --git a/dvbackup.sh b/dvbackup.sh index a796b16..7d70dac 100755 --- a/dvbackup.sh +++ b/dvbackup.sh @@ -21,7 +21,7 @@ backup() { test -z "$target_dir" && { echo "Error: No base folder found for target=$target" >&2; exit 2; } test -z "$target_name" && { echo "Error: No target name found for target=$target" >&2; exit 3; } - "$DOCKER" run --rm \ + echo_and_run "$DOCKER" run --rm \ --mount="type=volume,source=$volume,destination=/data,ro=true" \ --mount="type=bind,source=$target_dir,destination=/data2" \ busybox /bin/sh -c \ @@ -38,13 +38,11 @@ restore() { test -z "$target_dir" && { echo "Error: No base folder found for target=$target" >&2; exit 2; } test -z "$target_name" && { echo "Error: No target name found for target=$target" >&2; exit 3; } - set -x - "$DOCKER" run --rm \ + echo_and_run "$DOCKER" run --rm \ --mount="type=volume,source=$volume,destination=/data" \ --mount="type=bind,source=$target_dir,destination=/data2" \ busybox /bin/sh -c \ "cd /data/ && rm -rf ./* && tar xf '/data2/$target_name'" - set +x } backup_all() { @@ -57,6 +55,14 @@ backup_all() { } restore_all() { + if [ -z "$DVB_I_KNOW_WHAT_I_DO" ]; then + printf "The following operation will delete all data in the volumes to be restored, are you sure [y/N]? " + read -r DVB_I_KNOW_WHAT_I_DO + fi + if echo "$DVB_I_KNOW_WHAT_I_DO" | grep -Eviq 't|true|1|y|yes'; then + echo aborting + exit 1 + fi for tarball in "$@"; do volume_name="${tarball%.tar}" echo "$volume_name -> $volume"