From cfe3a2c011aa70025729d6073aafe87bf64f3586 Mon Sep 17 00:00:00 2001 From: Arvin Schnell Date: Fri, 11 Apr 2025 14:42:48 +0200 Subject: [PATCH] - added example wrapper script for btrfs command to be used by snbk --- scripts/snbk-btrfs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 scripts/snbk-btrfs diff --git a/scripts/snbk-btrfs b/scripts/snbk-btrfs new file mode 100755 index 00000000..39e816a3 --- /dev/null +++ b/scripts/snbk-btrfs @@ -0,0 +1,31 @@ +#!/bin/bash + +if [ "$#" -lt 3 ]; then + echo "Usage: $0 [subcommand] [options] -- /backup/..." + exit 1 +fi + +# Check "end of options" delimiter + +delimiter_arg="${@: -2:1}" + +if [[ "$delimiter_arg" != -- ]]; then + echo "Error: 'end of options' delimiter missing." + exit 1 +fi + +# Check path + +path_arg="${@: -1:1}" + +if ! path=$(realpath --canonicalize-existing "$path_arg"); then + echo "Error: Could not resolve the path '$path_arg'." + exit 1 +fi + +if [[ "$path" != /backup* ]]; then + echo "Error: The resolved path '$path' does not start with '/backup'." + exit 1 +fi + +exec sudo /usr/sbin/btrfs "$@" -- 2.47.3