diff --git a/scripts/lib/restoration.fish b/scripts/lib/restoration.fish index b1f63c9d..84475373 100644 --- a/scripts/lib/restoration.fish +++ b/scripts/lib/restoration.fish @@ -23,9 +23,10 @@ end function restoreFiles if [ -n "$VALHALLA_BACKUP_DIR" ] - argparse -i "user=" "base-directory=" -- $argv + set -l path (getArchivePath $argv) set -l tarArgs set -l sudoArgs + argparse -i "user=" "base-directory=" -- $argv if [ -n "$_flag_base_directory" ] set -a tarArgs -C "$_flag_base_directory" @@ -37,8 +38,8 @@ function restoreFiles set -a sudoArgs -u "$_flag_user" end - fetchArchive $argv | begin - sudo $sudoArgs tar $tarArgs -xvz + if runRestorationCommand test -f "$path" + runRestorationCommand cat "$path" | sudo $sudoArgs tar $tarArgs -xvz end end end @@ -47,11 +48,6 @@ function createArchive -a path runRestorationCommand sh -c "tee $(string escape -- "$path") >/dev/null" end -function fetchArchive - set -l path (getArchivePath $argv) - runRestorationCommand cat "$path" -end - function runRestorationCommand if [ -z "$VALHALLA_BACKUP_SERVER" ] $argv