Add restore script, use it to move the latest lock file to the destinations

This commit is contained in:
Martin Larsson 2024-01-23 13:38:47 +01:00
parent 0a91afa541
commit 9cb44a8932
3 changed files with 60 additions and 7 deletions

View file

@ -2,9 +2,6 @@
source ./util_lib.sh
# Enable the NULL_GLOB option to handle cases where no subdirectories exist
setopt NULL_GLOB
# Create a lock dir for our current configs.
((latest_lock=$(get_latest_lock) + 1))
lock_dir="$LOCK_ROOT"/"$latest_lock"
@ -21,10 +18,9 @@ for mapping in "${mappings[@]}"; do
# Check if destination directory exists
final="$dest/$src"
if [ -e "$final" ]; then
# If destination exists, move its contents to the .lock directory
mkdir -p "$lock_dest"
mv "$final"/* "$lock_dest"
echo "Moved existing contents of \"$final\" to \"$lock_dest\""
# mv "$final"/* "$lock_dest"
mv "$final" "$lock_dest"
echo "Moved \"$final\" to \"$lock_dest\""
fi
# Create destination directory